diff options
| author | Owen Jacobson <owen@grimoire.ca> | 2025-10-27 17:29:36 -0400 |
|---|---|---|
| committer | Owen Jacobson <owen@grimoire.ca> | 2025-10-28 01:27:13 -0400 |
| commit | 398bc79a3f1f4316e6cc33b6e6bce133c1db3e4c (patch) | |
| tree | f34f9ec001d2064b080b302fba175d66b08865ce /src/test | |
| parent | 2d05e6fb933d8c33078232b3bdfbc2aa05106d80 (diff) | |
Convert the `Conversations` component into a freestanding struct.
Unlike the previous example, this involves cloning an event broadcaster, as well. This is, per the documentation, how the type may be used. From <https://docs.rs/tokio/latest/tokio/sync/broadcast/fn.channel.html>:
> The Sender can be cloned to send to the same channel from multiple points in the process or it can be used concurrently from an `Arc`.
The language is less firm than the language sqlx uses for its pool, but the intent is clear enough, and it works in practice.
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/fixtures/conversation.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/test/fixtures/conversation.rs b/src/test/fixtures/conversation.rs index fb2f58d..f0d8c8c 100644 --- a/src/test/fixtures/conversation.rs +++ b/src/test/fixtures/conversation.rs @@ -1,3 +1,4 @@ +use axum::extract::FromRef; use faker_rand::{ en_us::{addresses::CityName, names::FullName}, faker_impl_from_templates, @@ -6,15 +7,17 @@ use faker_rand::{ use rand; use crate::{ - app::App, clock::RequestedAt, - conversation::{self, Conversation}, + conversation::{self, Conversation, app::Conversations}, name::Name, }; -pub async fn create(app: &App, created_at: &RequestedAt) -> Conversation { +pub async fn create<App>(app: &App, created_at: &RequestedAt) -> Conversation +where + Conversations: FromRef<App>, +{ let name = propose(); - app.conversations() + Conversations::from_ref(app) .create(&name, created_at) .await .expect("should always succeed if the conversation is actually new") |
