From daae2038f87223950adcfa4e2db39e2dc4972003 Mon Sep 17 00:00:00 2001 From: Kitaiti Makoto Date: Sun, 6 Mar 2022 20:22:36 +0900 Subject: [PATCH] Add test for Tag::from_activity() --- plume-models/src/tags.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/plume-models/src/tags.rs b/plume-models/src/tags.rs index 47ac9350..0460efc2 100644 --- a/plume-models/src/tags.rs +++ b/plume-models/src/tags.rs @@ -74,7 +74,7 @@ impl Tag { mod tests { use super::*; use crate::tests::db; - use crate::{diesel::Connection, instance::tests::fill_database}; + use crate::{diesel::Connection, inbox::tests::fill_database}; use assert_json_diff::assert_json_eq; use serde_json::to_value; @@ -102,6 +102,24 @@ mod tests { }) } + #[test] + fn from_activity() { + let conn = &db(); + conn.test_transaction::<_, Error, _>(|| { + let (posts, _users, _blogs) = fill_database(conn); + let post_id = posts[0].id; + let mut ht = Hashtag::default(); + ht.set_href_string(ap_url(&format!("https://plu.me/tag/a_tag")))?; + ht.set_name_string("a_tag".into())?; + let tag = Tag::from_activity(conn, &ht, post_id, true)?; + + assert_eq!(&tag.tag, "a_tag"); + assert!(tag.is_hashtag); + + Ok(()) + }); + } + #[test] fn build_activity() { let conn = &db();