Radish alpha
r
rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt
Git libraries for Radicle
Radicle
Git
surf: test serialization of tree
Fintan Halpenny committed 3 years ago
commit 0d5b6c4c30dfebf343b5867ddb0907b8dfc62e2e
parent 95c31f2
2 files changed +42 -0
modified radicle-surf/t/src/lib.rs
@@ -6,3 +6,6 @@ mod git;

#[cfg(test)]
mod file_system;
+

+
#[cfg(test)]
+
mod source;
added radicle-surf/t/src/source.rs
@@ -0,0 +1,39 @@
+
use std::path::Path;
+

+
use git_ref_format::refname;
+
use radicle_surf::{git::Repository, source};
+
use serde_json::json;
+

+
const GIT_PLATINUM: &str = "../data/git-platinum";
+

+
#[test]
+
fn tree_serialization() {
+
    let repo = Repository::open(GIT_PLATINUM).unwrap();
+
    let tree = source::Tree::new(
+
        &repo,
+
        &refname!("refs/heads/master"),
+
        Some(&Path::new("src")),
+
    )
+
    .unwrap();
+

+
    let expected = json!({
+
      "entries": [
+
        {
+
          "kind": "blob",
+
          "lastCommit": null,
+
          "name": "Eval.hs",
+
          "path": "src/Eval.hs"
+
        },
+
        {
+
          "kind": "blob",
+
          "lastCommit": null,
+
          "name": "memory.rs",
+
          "path": "src/memory.rs"
+
        }
+
      ],
+
      "lastCommit": null,
+
      "name": "src",
+
      "path": "src"
+
    });
+
    assert_eq!(serde_json::to_value(tree).unwrap(), expected)
+
}