Merge pull request 'Add test for Tag::from_activity()' (#1037) from tag-test into main
Reviewed-on: https://git.joinplu.me/Plume/Plume/pulls/1037
This commit is contained in:
commit
3cf52b3985
@ -74,7 +74,7 @@ impl Tag {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
use crate::tests::db;
|
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 assert_json_diff::assert_json_eq;
|
||||||
use serde_json::to_value;
|
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]
|
#[test]
|
||||||
fn build_activity() {
|
fn build_activity() {
|
||||||
let conn = &db();
|
let conn = &db();
|
||||||
|
Loading…
Reference in New Issue
Block a user