diff options
Diffstat (limited to 'src/channel/routes/test/list.rs')
| -rw-r--r-- | src/channel/routes/test/list.rs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/channel/routes/test/list.rs b/src/channel/routes/test/list.rs new file mode 100644 index 0000000..f7f7b44 --- /dev/null +++ b/src/channel/routes/test/list.rs @@ -0,0 +1,64 @@ +use axum::extract::State; + +use crate::{channel::routes, test::fixtures}; + +#[tokio::test] +async fn empty_list() { + // Set up the environment + + let app = fixtures::scratch_app().await; + let viewer = fixtures::login::create(&app).await; + + // Call the endpoint + + let routes::Channels(channels) = routes::list(State(app), viewer) + .await + .expect("always succeeds"); + + // Verify the semantics + + assert!(channels.is_empty()); +} + +#[tokio::test] +async fn one_channel() { + // Set up the environment + + let app = fixtures::scratch_app().await; + let viewer = fixtures::login::create(&app).await; + let channel = fixtures::channel::create(&app).await; + + // Call the endpoint + + let routes::Channels(channels) = routes::list(State(app), viewer) + .await + .expect("always succeeds"); + + // Verify the semantics + + assert!(channels.contains(&channel)); +} + +#[tokio::test] +async fn multiple_channels() { + // Set up the environment + + let app = fixtures::scratch_app().await; + let viewer = fixtures::login::create(&app).await; + let channels = vec![ + fixtures::channel::create(&app).await, + fixtures::channel::create(&app).await, + ]; + + // Call the endpoint + + let routes::Channels(response_channels) = routes::list(State(app), viewer) + .await + .expect("always succeeds"); + + // Verify the semantics + + assert!(channels + .into_iter() + .all(|channel| response_channels.contains(&channel))); +} |
