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

use crate::{
    app::App,
    channel::Channel,
    clock::RequestedAt,
    message::{self, Body, Message},
    user::User,
};

pub async fn send(app: &App, channel: &Channel, sender: &User, sent_at: &RequestedAt) -> Message {
    let body = propose();

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

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

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