]> Untitled Git - lemmy.git/blobdiff - crates/apub/src/protocol/mod.rs
Create and Note always need to tag parent creator, for mastodon notifications
[lemmy.git] / crates / apub / src / protocol / mod.rs
index f587dba7e45f0d5cc4db64d141a108030d3f7bb9..37a29f8fa0c8e70d68445bb58311d5a9a131b392 100644 (file)
@@ -22,3 +22,22 @@ pub struct ImageObject {
   pub(crate) kind: ImageType,
   pub(crate) url: Url,
 }
+
+#[cfg(test)]
+pub(crate) mod tests {
+  use crate::objects::tests::file_to_json_object;
+  use assert_json_diff::assert_json_include;
+  use serde::{de::DeserializeOwned, Serialize};
+  use std::collections::HashMap;
+
+  pub(crate) fn test_parse_lemmy_item<T: Serialize + DeserializeOwned + std::fmt::Debug>(
+    path: &str,
+  ) -> T {
+    let parsed = file_to_json_object::<T>(path);
+
+    // ensure that no field is ignored when parsing
+    let raw = file_to_json_object::<HashMap<String, serde_json::Value>>(path);
+    assert_json_include!(actual: &parsed, expected: raw);
+    parsed
+  }
+}