summaryrefslogtreecommitdiff
path: root/src/boot
diff options
context:
space:
mode:
Diffstat (limited to 'src/boot')
-rw-r--r--src/boot/app.rs16
-rw-r--r--src/boot/handlers/boot/test.rs81
2 files changed, 49 insertions, 48 deletions
diff --git a/src/boot/app.rs b/src/boot/app.rs
index 89eec12..0ed5d1b 100644
--- a/src/boot/app.rs
+++ b/src/boot/app.rs
@@ -3,7 +3,7 @@ use sqlx::sqlite::SqlitePool;
use super::Snapshot;
use crate::{
- channel::{self, repo::Provider as _},
+ conversation::{self, repo::Provider as _},
event::{Event, Sequence, repo::Provider as _},
message::{self, repo::Provider as _},
name,
@@ -24,7 +24,7 @@ impl<'a> Boot<'a> {
let resume_point = tx.sequence().current().await?;
let users = tx.users().all(resume_point).await?;
- let channels = tx.channels().all(resume_point).await?;
+ let conversations = tx.conversations().all(resume_point).await?;
let messages = tx.messages().all(resume_point).await?;
tx.commit().await?;
@@ -36,9 +36,9 @@ impl<'a> Boot<'a> {
.filter(Sequence::up_to(resume_point))
.map(Event::from);
- let channel_events = channels
+ let conversation_events = conversations
.iter()
- .map(channel::History::events)
+ .map(conversation::History::events)
.kmerge_by(Sequence::merge)
.filter(Sequence::up_to(resume_point))
.map(Event::from);
@@ -51,7 +51,7 @@ impl<'a> Boot<'a> {
.map(Event::from);
let events = user_events
- .merge_by(channel_events, Sequence::merge)
+ .merge_by(conversation_events, Sequence::merge)
.merge_by(message_events, Sequence::merge)
.collect();
@@ -79,9 +79,9 @@ impl From<user::repo::LoadError> for Error {
}
}
-impl From<channel::repo::LoadError> for Error {
- fn from(error: channel::repo::LoadError) -> Self {
- use channel::repo::LoadError;
+impl From<conversation::repo::LoadError> for Error {
+ fn from(error: conversation::repo::LoadError) -> Self {
+ use conversation::repo::LoadError;
match error {
LoadError::Name(error) => error.into(),
LoadError::Database(error) => error.into(),
diff --git a/src/boot/handlers/boot/test.rs b/src/boot/handlers/boot/test.rs
index 1e590a7..c7c511a 100644
--- a/src/boot/handlers/boot/test.rs
+++ b/src/boot/handlers/boot/test.rs
@@ -37,9 +37,9 @@ async fn includes_users() {
}
#[tokio::test]
-async fn includes_channels() {
+async fn includes_conversations() {
let app = fixtures::scratch_app().await;
- let channel = fixtures::channel::create(&app, &fixtures::now()).await;
+ let conversation = fixtures::conversation::create(&app, &fixtures::now()).await;
let viewer = fixtures::identity::fictitious();
let response = super::handler(State(app), viewer)
@@ -50,19 +50,19 @@ async fn includes_channels() {
.snapshot
.events
.into_iter()
- .filter_map(fixtures::event::channel)
- .filter_map(fixtures::event::channel::created)
+ .filter_map(fixtures::event::conversation)
+ .filter_map(fixtures::event::conversation::created)
.exactly_one()
- .expect("only one channel has been created");
- assert_eq!(channel, created.channel);
+ .expect("only one conversation has been created");
+ assert_eq!(conversation, created.conversation);
}
#[tokio::test]
async fn includes_messages() {
let app = fixtures::scratch_app().await;
let sender = fixtures::user::create(&app, &fixtures::now()).await;
- let channel = fixtures::channel::create(&app, &fixtures::now()).await;
- let message = fixtures::message::send(&app, &channel, &sender, &fixtures::now()).await;
+ let conversation = fixtures::conversation::create(&app, &fixtures::now()).await;
+ let message = fixtures::message::send(&app, &conversation, &sender, &fixtures::now()).await;
let viewer = fixtures::identity::fictitious();
let response = super::handler(State(app), viewer)
@@ -84,9 +84,9 @@ async fn includes_messages() {
async fn includes_expired_messages() {
let app = fixtures::scratch_app().await;
let sender = fixtures::user::create(&app, &fixtures::ancient()).await;
- let channel = fixtures::channel::create(&app, &fixtures::ancient()).await;
+ let conversation = fixtures::conversation::create(&app, &fixtures::ancient()).await;
let expired_message =
- fixtures::message::send(&app, &channel, &sender, &fixtures::ancient()).await;
+ fixtures::message::send(&app, &conversation, &sender, &fixtures::ancient()).await;
app.messages()
.expire(&fixtures::now())
@@ -126,8 +126,9 @@ async fn includes_expired_messages() {
async fn includes_deleted_messages() {
let app = fixtures::scratch_app().await;
let sender = fixtures::user::create(&app, &fixtures::now()).await;
- let channel = fixtures::channel::create(&app, &fixtures::now()).await;
- let deleted_message = fixtures::message::send(&app, &channel, &sender, &fixtures::now()).await;
+ let conversation = fixtures::conversation::create(&app, &fixtures::now()).await;
+ let deleted_message =
+ fixtures::message::send(&app, &conversation, &sender, &fixtures::now()).await;
app.messages()
.delete(&sender, &deleted_message.id, &fixtures::now())
@@ -164,11 +165,11 @@ async fn includes_deleted_messages() {
}
#[tokio::test]
-async fn includes_expired_channels() {
+async fn includes_expired_conversations() {
let app = fixtures::scratch_app().await;
- let expired_channel = fixtures::channel::create(&app, &fixtures::ancient()).await;
+ let expired_conversation = fixtures::conversation::create(&app, &fixtures::ancient()).await;
- app.channels()
+ app.conversations()
.expire(&fixtures::now())
.await
.expect("expiry never fails");
@@ -183,34 +184,34 @@ async fn includes_expired_channels() {
.events
.iter()
.cloned()
- .filter_map(fixtures::event::channel)
- .filter_map(fixtures::event::channel::created)
+ .filter_map(fixtures::event::conversation)
+ .filter_map(fixtures::event::conversation::created)
.exactly_one()
- .expect("only one channel has been created");
- // We don't expect `expired_channel` to match the event exactly, as the name will have been
- // tombstoned and the channel given a `deleted_at` date.
- assert_eq!(expired_channel.id, created.channel.id);
+ .expect("only one conversation has been created");
+ // We don't expect `expired_conversation` to match the event exactly, as the name will
+ // have been tombstoned and the conversation given a `deleted_at` date.
+ assert_eq!(expired_conversation.id, created.conversation.id);
let deleted = response
.snapshot
.events
.into_iter()
- .filter_map(fixtures::event::channel)
- .filter_map(fixtures::event::channel::deleted)
+ .filter_map(fixtures::event::conversation)
+ .filter_map(fixtures::event::conversation::deleted)
.exactly_one()
- .expect("only one channel has expired");
- assert_eq!(expired_channel.id, deleted.id);
+ .expect("only one conversation has expired");
+ assert_eq!(expired_conversation.id, deleted.id);
}
#[tokio::test]
-async fn includes_deleted_channels() {
+async fn includes_deleted_conversations() {
let app = fixtures::scratch_app().await;
- let deleted_channel = fixtures::channel::create(&app, &fixtures::now()).await;
+ let deleted_conversation = fixtures::conversation::create(&app, &fixtures::now()).await;
- app.channels()
- .delete(&deleted_channel.id, &fixtures::now())
+ app.conversations()
+ .delete(&deleted_conversation.id, &fixtures::now())
.await
- .expect("deleting a valid channel succeeds");
+ .expect("deleting a valid conversation succeeds");
let viewer = fixtures::identity::fictitious();
let response = super::handler(State(app), viewer)
@@ -222,21 +223,21 @@ async fn includes_deleted_channels() {
.events
.iter()
.cloned()
- .filter_map(fixtures::event::channel)
- .filter_map(fixtures::event::channel::created)
+ .filter_map(fixtures::event::conversation)
+ .filter_map(fixtures::event::conversation::created)
.exactly_one()
- .expect("only one channel has been created");
- // We don't expect `deleted_channel` to match the event exactly, as the name will have been
- // tombstoned and the channel given a `deleted_at` date.
- assert_eq!(deleted_channel.id, created.channel.id);
+ .expect("only one conversation has been created");
+ // We don't expect `deleted_conversation` to match the event exactly, as the name will
+ // have been tombstoned and the conversation given a `deleted_at` date.
+ assert_eq!(deleted_conversation.id, created.conversation.id);
let deleted = response
.snapshot
.events
.into_iter()
- .filter_map(fixtures::event::channel)
- .filter_map(fixtures::event::channel::deleted)
+ .filter_map(fixtures::event::conversation)
+ .filter_map(fixtures::event::conversation::deleted)
.exactly_one()
- .expect("only one channel has been deleted");
- assert_eq!(deleted_channel.id, deleted.id);
+ .expect("only one conversation has been deleted");
+ assert_eq!(deleted_conversation.id, deleted.id);
}