Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: Add test for two-hop case
Fintan Halpenny committed 22 days ago
commit 540827acec99775e951b01e36290639f6463d460
parent 259b4d37257e5b886696b3b976544529cfceccf6
1 file changed +17 -0
modified crates/radicle/src/git/canonical/symbolic.rs
@@ -368,6 +368,23 @@ mod test {
        );
    }

+
    /// Verifies that resolution works correctly for chains with 2 links
+
    /// (even-length), e.g. `HEAD → MAIN → refs/heads/master`.
+
    #[test]
+
    fn resolve_two_hop_chain() {
+
        let symrefs = serde_json::from_value::<SymbolicRefs>(serde_json::json!({
+
            "MAIN": "refs/heads/master",
+
            "HEAD": "MAIN",
+
        }))
+
        .unwrap();
+

+
        // HEAD → MAIN → refs/heads/master should resolve to refs/heads/master
+
        assert_eq!(
+
            symrefs.resolve_head().map(|r| r.as_str()),
+
            Some("refs/heads/master"),
+
        );
+
    }
+

    /// Motivates why we cannot simply delegate to [`BTreeMap::extend`]
    /// for combining [`SymbolicRefs`].
    #[test]