Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: Add examples and unit tests
✗ CI failure Erik Kundt committed 7 months ago
commit 917a84b6cea081725eb3c0d187688528b53a1e11
parent 2b1539ce0df38d848aedd2998220fc19667a8db3
2 failed (2 total) View logs
1 file changed +31 -1
modified crates/radicle-cli/src/commands/publish/args.rs
@@ -1,3 +1,5 @@
+
use radicle::identity::RepoId;
+

pub(crate) const ABOUT: &str = "Publish a repository to the network";

const LONG_ABOUT: &str = r#"
@@ -16,6 +18,34 @@ command must be used."#;
#[command(about = ABOUT, long_about = LONG_ABOUT, disable_version_flag = true)]
pub struct Args {
    /// The Repository ID of the repository to publish
+
    ///
+
    /// [example values: rad:z3Tr6bC7ctEg2EHmLvknUr29mEDLH, z3Tr6bC7ctEg2EHmLvknUr29mEDLH]
    #[arg(value_name = "RID")]
-
    pub(super) rid: Option<radicle::identity::RepoId>,
+
    pub(super) rid: Option<RepoId>,
+
}
+

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

+
    #[test]
+
    fn should_parse_rid_non_urn() {
+
        let args = Args::try_parse_from(["publish", "z3Tr6bC7ctEg2EHmLvknUr29mEDLH"]);
+
        assert!(args.is_ok())
+
    }
+

+
    #[test]
+
    fn should_parse_rid_urn() {
+
        let args = Args::try_parse_from(["publish", "rad:z3Tr6bC7ctEg2EHmLvknUr29mEDLH"]);
+
        assert!(args.is_ok())
+
    }
+

+
    #[test]
+
    fn should_not_parse_rid_url() {
+
        let err =
+
            Args::try_parse_from(["publish", "rad://z3Tr6bC7ctEg2EHmLvknUr29mEDLH"]).unwrap_err();
+
        assert_eq!(err.kind(), ErrorKind::ValueValidation);
+
    }
}