summaryrefslogtreecommitdiff
path: root/src/invite/routes/test.rs
blob: 4d99660876b9d08a76e5e1ba7492e9c911bee519 (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
use axum::extract::{Json, State};

use super::post;
use crate::test::fixtures;

#[tokio::test]
async fn create_invite() {
    // Set up the environment

    let app = fixtures::scratch_app().await;
    let issuer = fixtures::identity::create(&app, &fixtures::now()).await;
    let issued_at = fixtures::now();

    // Call the endpoint

    let Json(invite) = post::handler(
        State(app),
        issued_at.clone(),
        issuer.clone(),
        Json(post::Request {}),
    )
    .await
    .expect("creating an invite always succeeds");

    // Verify the response
    assert_eq!(issuer.login.id, invite.issuer);
    assert_eq!(&*issued_at, &invite.issued_at);
}