Radish alpha
r
Radicle CI broker
Radicle
Git (anonymous pull)
Log in to clone via SSH
refactor(src/event.rs): handle error without panic in tests
Lars Wirzenius committed 1 year ago
commit 89f88e92182ca68c8a7ad89cad4ec3b15d8b3af3
parent aea1347c5c653d7b375088c072e95e9a87809e80
1 file changed +8 -6
modified src/event.rs
@@ -616,13 +616,14 @@ mod test_parse_ref {
    }

    #[test]
-
    fn namespaced_patch() {
+
    fn namespaced_patch() -> anyhow::Result<()> {
        log_init();
        const SHA: &str = "0a4c69183fc8b8d849f5ab977d70f2a1f4788bca";
        assert_eq!(
            parse_ref(&format!("refs/namespaces/NID/refs/heads/patches/{SHA}")),
-
            Some(ParsedRef::Patch(Oid::try_from(SHA).unwrap()))
+
            Some(ParsedRef::Patch(Oid::try_from(SHA)?))
        );
+
        Ok(())
    }
}

@@ -651,17 +652,18 @@ mod test {
    use super::{is_patch_update, log_init, parse_ref, push_branch, Oid, ParsedRef};

    #[test]
-
    fn test_parse_patch_ref() {
+
    fn test_parse_patch_ref() -> anyhow::Result<()> {
        log_init();
        let patch_ref =
            "refs/namespaces/NID/refs/heads/patches/9183ed6232687d3105482960cecb01a53018b80a";

        assert_eq!(
            parse_ref(patch_ref),
-
            Some(ParsedRef::Patch(
-
                Oid::try_from("9183ed6232687d3105482960cecb01a53018b80a").unwrap()
-
            ))
+
            Some(ParsedRef::Patch(Oid::try_from(
+
                "9183ed6232687d3105482960cecb01a53018b80a"
+
            )?))
        );
+
        Ok(())
    }

    #[test]