From a15e3d580124f561864c6a39f1e035eb1b3aab13 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Mon, 30 Jun 2025 22:00:57 -0400 Subject: Rename "channel" to "conversation" within the server. I've split this from the schema and API changes because, frankly, it's huge. Annoyingly so. There are no semantic changes in this, it's all symbol changes, but there are a _lot_ of them because the term "channel" leaks all over everything in a service whose primary role is managing messages sent to channels (now, conversations). I found a buggy test while working on this! It's not fixed in this commit, because it felt mean to hide a real change in the middle of this much chaff. --- src/test/fixtures/channel.rs | 38 -------------------------------------- src/test/fixtures/conversation.rs | 38 ++++++++++++++++++++++++++++++++++++++ src/test/fixtures/event/mod.rs | 6 +++--- src/test/fixtures/event/stream.rs | 14 +++++++------- src/test/fixtures/message.rs | 13 +++++++++---- src/test/fixtures/mod.rs | 2 +- 6 files changed, 58 insertions(+), 53 deletions(-) delete mode 100644 src/test/fixtures/channel.rs create mode 100644 src/test/fixtures/conversation.rs (limited to 'src/test') diff --git a/src/test/fixtures/channel.rs b/src/test/fixtures/channel.rs deleted file mode 100644 index 98048f2..0000000 --- a/src/test/fixtures/channel.rs +++ /dev/null @@ -1,38 +0,0 @@ -use faker_rand::{ - en_us::{addresses::CityName, names::FullName}, - faker_impl_from_templates, - lorem::Paragraphs, -}; -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::().to_string().into() -} - -pub fn propose_invalid_name() -> Name { - rand::random::().to_string().into() -} - -struct NameTemplate(String); -faker_impl_from_templates! { - NameTemplate; "{} {}", CityName, FullName; -} - -pub fn fictitious() -> channel::Id { - channel::Id::generate() -} diff --git a/src/test/fixtures/conversation.rs b/src/test/fixtures/conversation.rs new file mode 100644 index 0000000..fb2f58d --- /dev/null +++ b/src/test/fixtures/conversation.rs @@ -0,0 +1,38 @@ +use faker_rand::{ + en_us::{addresses::CityName, names::FullName}, + faker_impl_from_templates, + lorem::Paragraphs, +}; +use rand; + +use crate::{ + app::App, + clock::RequestedAt, + conversation::{self, Conversation}, + name::Name, +}; + +pub async fn create(app: &App, created_at: &RequestedAt) -> Conversation { + let name = propose(); + app.conversations() + .create(&name, created_at) + .await + .expect("should always succeed if the conversation is actually new") +} + +pub fn propose() -> Name { + rand::random::().to_string().into() +} + +pub fn propose_invalid_name() -> Name { + rand::random::().to_string().into() +} + +struct NameTemplate(String); +faker_impl_from_templates! { + NameTemplate; "{} {}", CityName, FullName; +} + +pub fn fictitious() -> conversation::Id { + conversation::Id::generate() +} diff --git a/src/test/fixtures/event/mod.rs b/src/test/fixtures/event/mod.rs index 691cdeb..69c79d8 100644 --- a/src/test/fixtures/event/mod.rs +++ b/src/test/fixtures/event/mod.rs @@ -2,7 +2,7 @@ use crate::event::Event; pub mod stream; -pub fn channel(event: Event) -> Option { +pub fn conversation(event: Event) -> Option { match event { Event::Channel(channel) => Some(channel), _ => None, @@ -23,8 +23,8 @@ pub fn user(event: Event) -> Option { } } -pub mod channel { - use crate::channel::{Event, event}; +pub mod conversation { + use crate::conversation::{Event, event}; pub fn created(event: Event) -> Option { match event { diff --git a/src/test/fixtures/event/stream.rs b/src/test/fixtures/event/stream.rs index 6c2a1bf..5b3621d 100644 --- a/src/test/fixtures/event/stream.rs +++ b/src/test/fixtures/event/stream.rs @@ -2,8 +2,8 @@ use std::future::{self, Ready}; use crate::{event::Event, test::fixtures::event}; -pub fn channel(event: Event) -> Ready> { - future::ready(event::channel(event)) +pub fn conversation(event: Event) -> Ready> { + future::ready(event::conversation(event)) } pub fn message(event: Event) -> Ready> { @@ -14,20 +14,20 @@ pub fn user(event: Event) -> Ready> { future::ready(event::user(event)) } -pub mod channel { +pub mod conversation { use std::future::{self, Ready}; use crate::{ - channel::{Event, event}, - test::fixtures::event::channel, + conversation::{Event, event}, + test::fixtures::event::conversation, }; pub fn created(event: Event) -> Ready> { - future::ready(channel::created(event)) + future::ready(conversation::created(event)) } pub fn deleted(event: Event) -> Ready> { - future::ready(channel::deleted(event)) + future::ready(conversation::deleted(event)) } } diff --git a/src/test/fixtures/message.rs b/src/test/fixtures/message.rs index 2254915..03f8072 100644 --- a/src/test/fixtures/message.rs +++ b/src/test/fixtures/message.rs @@ -2,19 +2,24 @@ use faker_rand::lorem::Paragraphs; use crate::{ app::App, - channel::Channel, clock::RequestedAt, + conversation::Conversation, message::{self, Body, Message}, user::User, }; -pub async fn send(app: &App, channel: &Channel, sender: &User, sent_at: &RequestedAt) -> Message { +pub async fn send( + app: &App, + conversation: &Conversation, + sender: &User, + sent_at: &RequestedAt, +) -> Message { let body = propose(); app.messages() - .send(&channel.id, sender, sent_at, &body) + .send(&conversation.id, sender, sent_at, &body) .await - .expect("should succeed if the channel exists") + .expect("should succeed if the conversation exists") } pub fn propose() -> Body { diff --git a/src/test/fixtures/mod.rs b/src/test/fixtures/mod.rs index 418bdb5..87d3fa1 100644 --- a/src/test/fixtures/mod.rs +++ b/src/test/fixtures/mod.rs @@ -3,7 +3,7 @@ use chrono::{TimeDelta, Utc}; use crate::{app::App, clock::RequestedAt, db}; pub mod boot; -pub mod channel; +pub mod conversation; pub mod cookie; pub mod event; pub mod future; -- cgit v1.2.3