blob: f7f7b44a17aa7e1644fe9fb1d1feab7485459835 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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)));
}
|