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

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) = super::handler(
        State(app),
        issued_at.clone(),
        issuer.clone(),
        Json(super::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);
}