Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli/unfollow: Add unit tests around NID / DID parsing
✗ CI failure Erik Kundt committed 7 months ago
commit 6562e5c4e4c1370a05f5f9d22c176b66ddc3fd35
parent 77c818516c4573d38649c19a0290b7b3940afaa9
2 failed 1 pending (3 total) View logs
1 file changed +33 -0
modified crates/radicle-cli/src/commands/unfollow.rs
@@ -25,3 +25,36 @@ pub fn run(options: Args, ctx: impl term::Context) -> anyhow::Result<()> {
    }
    Ok(())
}
+

+
#[cfg(test)]
+
mod test {
+
    use clap::error::ErrorKind;
+
    use clap::Parser;
+

+
    use super::Args;
+

+
    #[test]
+
    fn should_parse_nid() {
+
        let args = Args::try_parse_from([
+
            "unfollow",
+
            "z6MksmpU5b1dS7oaqF2bHXhQi1DWy2hB7Mh9CuN7y1DN6QSz",
+
        ]);
+
        assert!(args.is_ok())
+
    }
+

+
    #[test]
+
    fn should_parse_did() {
+
        let args = Args::try_parse_from([
+
            "unfollow",
+
            "did:key:z6MksmpU5b1dS7oaqF2bHXhQi1DWy2hB7Mh9CuN7y1DN6QSz",
+
        ]);
+
        assert!(args.is_ok())
+
    }
+

+
    #[test]
+
    fn should_not_parse() {
+
        let err = Args::try_parse_from(["unfollow", "bee"]).unwrap_err();
+

+
        assert_eq!(err.kind(), ErrorKind::ValueValidation);
+
    }
+
}