summaryrefslogtreecommitdiff
path: root/src/test/fixtures/channel.rs
diff options
context:
space:
mode:
authorKit La Touche <kit@transneptune.net>2024-10-23 21:56:31 -0400
committerKit La Touche <kit@transneptune.net>2024-10-23 21:56:31 -0400
commit1f769855df2d9cf2bca883a0475670f227e3678b (patch)
tree6c94d9c868eb022588a07245df978478034ac5dd /src/test/fixtures/channel.rs
parent8f360dd9cc45bb14431238ccc5e3d137c020fa7b (diff)
parent461814e5174cef1be3e07b4e4069314e9bcbedd6 (diff)
Merge branch 'main' into wip/mobile
Diffstat (limited to 'src/test/fixtures/channel.rs')
-rw-r--r--src/test/fixtures/channel.rs36
1 files changed, 31 insertions, 5 deletions
diff --git a/src/test/fixtures/channel.rs b/src/test/fixtures/channel.rs
index b678717..8cb38ae 100644
--- a/src/test/fixtures/channel.rs
+++ b/src/test/fixtures/channel.rs
@@ -1,10 +1,18 @@
+use std::future;
+
use faker_rand::{
en_us::{addresses::CityName, names::FullName},
faker_impl_from_templates,
};
use rand;
-use crate::{app::App, channel::Channel, clock::RequestedAt};
+use crate::{
+ app::App,
+ channel::{self, Channel},
+ clock::RequestedAt,
+ event::Event,
+ name::Name,
+};
pub async fn create(app: &App, created_at: &RequestedAt) -> Channel {
let name = propose();
@@ -14,11 +22,29 @@ pub async fn create(app: &App, created_at: &RequestedAt) -> Channel {
.expect("should always succeed if the channel is actually new")
}
-pub fn propose() -> String {
- rand::random::<Name>().to_string()
+pub fn propose() -> Name {
+ rand::random::<NameTemplate>().to_string().into()
}
-struct Name(String);
+struct NameTemplate(String);
faker_impl_from_templates! {
- Name; "{} {}", CityName, FullName;
+ NameTemplate; "{} {}", CityName, FullName;
+}
+
+pub fn events(event: Event) -> future::Ready<Option<channel::Event>> {
+ future::ready(match event {
+ Event::Channel(channel) => Some(channel),
+ _ => None,
+ })
+}
+
+pub fn created(event: channel::Event) -> future::Ready<Option<channel::event::Created>> {
+ future::ready(match event {
+ channel::Event::Created(event) => Some(event),
+ channel::Event::Deleted(_) => None,
+ })
+}
+
+pub fn fictitious() -> channel::Id {
+ channel::Id::generate()
}