summaryrefslogtreecommitdiff
path: root/src/test/fixtures/channel.rs
blob: 0c6480b1c23731abe7e5745e114ca151cb1fc7c3 (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
use faker_rand::{
    en_us::{addresses::CityName, names::FullName},
    faker_impl_from_templates,
};
use rand;

use crate::{
    app::App,
    channel::{self, Channel},
    clock::RequestedAt,
    name::Name,
};

pub async fn create(app: &App, created_at: &RequestedAt) -> Channel {
    let name = propose();
    app.channels()
        .create(&name, created_at)
        .await
        .expect("should always succeed if the channel is actually new")
}

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

struct NameTemplate(String);
faker_impl_from_templates! {
    NameTemplate; "{} {}", CityName, FullName;
}

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