mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-10-25 14:20:31 +08:00
surf: test serialization of tree
Confirm that the serialization of `source::Tree` has the expected output. Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com> X-Clacks-Overhead: GNU Terry Pratchett
This commit is contained in:
@@ -6,3 +6,6 @@ mod git;
|
||||
|
||||
#[cfg(test)]
|
||||
mod file_system;
|
||||
|
||||
#[cfg(test)]
|
||||
mod source;
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
Reference in New Issue
Block a user