diff options
| author | Kit La Touche <kit@transneptune.net> | 2024-10-10 13:26:15 -0400 |
|---|---|---|
| committer | Kit La Touche <kit@transneptune.net> | 2024-10-10 13:26:15 -0400 |
| commit | 03f8d9ad603a4e523a0e2a0e60ad62c8725f0875 (patch) | |
| tree | b01543c0c2dadbd4be17320d47fc2e3d2fdb280d /src/channel/routes/test | |
| parent | efae871b1bdb1e01081a44218281950cf0177f3b (diff) | |
| parent | d173bc08f2b699f58c8cca752ff688ad46f33ced (diff) | |
Merge branch 'main' into wip/path-routing-for-channels
Diffstat (limited to 'src/channel/routes/test')
| -rw-r--r-- | src/channel/routes/test/on_create.rs | 10 | ||||
| -rw-r--r-- | src/channel/routes/test/on_send.rs | 24 |
2 files changed, 16 insertions, 18 deletions
diff --git a/src/channel/routes/test/on_create.rs b/src/channel/routes/test/on_create.rs index ed49017..eeecc7f 100644 --- a/src/channel/routes/test/on_create.rs +++ b/src/channel/routes/test/on_create.rs @@ -2,7 +2,7 @@ use axum::extract::{Json, State}; use futures::stream::StreamExt as _; use crate::{ - channel::{app, routes}, + channel::{self, app, routes}, event, test::fixtures::{self, future::Immediately as _}, }; @@ -12,7 +12,7 @@ async fn new_channel() { // Set up the environment let app = fixtures::scratch_app().await; - let creator = fixtures::login::create(&app).await; + let creator = fixtures::login::create(&app, &fixtures::now()).await; // Call the endpoint @@ -53,8 +53,8 @@ async fn new_channel() { .expect("creation event published"); assert!(matches!( - event.kind, - event::Kind::ChannelCreated(event) + event, + event::Event::Channel(channel::Event::Created(event)) if event.channel == response_channel )); } @@ -64,7 +64,7 @@ async fn duplicate_name() { // Set up the environment let app = fixtures::scratch_app().await; - let creator = fixtures::login::create(&app).await; + let creator = fixtures::login::create(&app, &fixtures::now()).await; let channel = fixtures::channel::create(&app, &fixtures::now()).await; // Call the endpoint diff --git a/src/channel/routes/test/on_send.rs b/src/channel/routes/test/on_send.rs index 3297093..293cc56 100644 --- a/src/channel/routes/test/on_send.rs +++ b/src/channel/routes/test/on_send.rs @@ -4,8 +4,8 @@ use futures::stream::StreamExt; use crate::{ channel, channel::routes, - event, - message::app::SendError, + event::{self, Sequenced}, + message::{self, app::SendError}, test::fixtures::{self, future::Immediately as _}, }; @@ -14,7 +14,7 @@ async fn messages_in_order() { // Set up the environment let app = fixtures::scratch_app().await; - let sender = fixtures::login::create(&app).await; + let sender = fixtures::login::create(&app, &fixtures::now()).await; let channel = fixtures::channel::create(&app, &fixtures::now()).await; // Call the endpoint (twice) @@ -24,10 +24,8 @@ async fn messages_in_order() { (fixtures::now(), fixtures::message::propose()), ]; - for (sent_at, message) in &requests { - let request = routes::SendRequest { - message: message.clone(), - }; + for (sent_at, body) in &requests { + let request = routes::SendRequest { body: body.clone() }; routes::on_send( State(app.clone()), @@ -53,11 +51,11 @@ async fn messages_in_order() { let events = events.collect::<Vec<_>>().immediately().await; for ((sent_at, message), event) in requests.into_iter().zip(events) { - assert_eq!(*sent_at, event.instant.at); + assert_eq!(*sent_at, event.at()); assert!(matches!( - event.kind, - event::Kind::MessageSent(event) - if event.message.sender == sender + event, + event::Event::Message(message::Event::Sent(event)) + if event.message.sender == sender.id && event.message.body == message )); } @@ -68,14 +66,14 @@ async fn nonexistent_channel() { // Set up the environment let app = fixtures::scratch_app().await; - let login = fixtures::login::create(&app).await; + let login = fixtures::login::create(&app, &fixtures::now()).await; // Call the endpoint let sent_at = fixtures::now(); let channel = channel::Id::generate(); let request = routes::SendRequest { - message: fixtures::message::propose(), + body: fixtures::message::propose(), }; let routes::SendErrorResponse(error) = routes::on_send( State(app), |
