Skip to content

Commit

Permalink
twiq: Add UserCreated::r#type
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Sep 24, 2022
1 parent 7db517a commit f1b20a2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions twiq/crates/domain/src/aggregate/user/event.rs
Expand Up @@ -79,8 +79,10 @@ mod tests {

#[test]
fn user_created_test() -> anyhow::Result<()> {
// FIXME: remove impl serde::Deserialize for Event
let o = Event::from(UserCreated {
id: "0ecb46f3-01a1-49b2-9405-0b4c40ecefe8".to_owned(),
r#type: "user_created".to_owned(),
at: "2022-09-06T22:58:00.000000000Z".to_owned(),
stream_id: "a748c956-7e53-45ef-b1f0-1c52676a467c".to_owned(),
stream_seq: 1,
Expand Down
4 changes: 4 additions & 0 deletions twiq/crates/domain/src/aggregate/user/event/user_created.rs
Expand Up @@ -10,6 +10,7 @@ use crate::value::{At, TwitterUserId};
#[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct UserCreated {
pub(super) id: String,
pub(super) r#type: String,
pub(super) at: String,
pub(super) stream_id: String,
pub(super) stream_seq: u32,
Expand All @@ -26,6 +27,7 @@ impl UserCreated {
) -> Self {
Self {
id: id.to_string(),
r#type: crate::event::EventType::UserCreated.to_string(),
at: at.to_string(),
stream_id: stream_id.to_string(),
stream_seq: u32::from(stream_seq),
Expand Down Expand Up @@ -56,13 +58,15 @@ mod tests {
fn test() -> anyhow::Result<()> {
let o = UserCreated {
id: "0ecb46f3-01a1-49b2-9405-0b4c40ecefe8".to_owned(),
r#type: "user_created".to_owned(),
at: "2022-09-06T22:58:00.000000000Z".to_owned(),
stream_id: "a748c956-7e53-45ef-b1f0-1c52676a467c".to_owned(),
stream_seq: 1,
twitter_user_id: "twitter_user_id1".to_owned(),
};
let s = r#"{
"id": "0ecb46f3-01a1-49b2-9405-0b4c40ecefe8",
"type": "user_created",
"at": "2022-09-06T22:58:00.000000000Z",
"stream_id": "a748c956-7e53-45ef-b1f0-1c52676a467c",
"stream_seq": 1,
Expand Down

0 comments on commit f1b20a2

Please sign in to comment.