summaryrefslogtreecommitdiff
path: root/src/test/fixtures/message.rs
blob: 92ac1f564a61e74c9803c327acd0746886cbcd12 (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
use faker_rand::lorem::Paragraphs;

use crate::{
    app::App,
    clock::RequestedAt,
    conversation::Conversation,
    login::Login,
    message::{self, Body, Message},
};

pub async fn send(
    app: &App,
    conversation: &Conversation,
    sender: &Login,
    sent_at: &RequestedAt,
) -> Message {
    let body = propose();

    app.messages()
        .send(&conversation.id, sender, sent_at, &body)
        .await
        .expect("should succeed if the conversation exists")
}

pub fn propose() -> Body {
    rand::random::<Paragraphs>().to_string().into()
}

pub fn fictitious() -> message::Id {
    message::Id::generate()
}