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))); }