test for is_tag
This commit is contained in:
parent
ca44db83d6
commit
970096b3d4
1 changed files with 15 additions and 1 deletions
16
src/main.rs
16
src/main.rs
|
@ -29,12 +29,16 @@ fn release(conf: &Config) -> Release {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn is_tag<R>(gitref: R) -> bool where R: AsRef<str> {
|
||||||
|
gitref.as_ref().starts_with("refs/tags/")
|
||||||
|
}
|
||||||
|
|
||||||
fn run(
|
fn run(
|
||||||
conf: Config,
|
conf: Config,
|
||||||
releaser: &dyn Releaser,
|
releaser: &dyn Releaser,
|
||||||
uploader: &dyn AssetUploader,
|
uploader: &dyn AssetUploader,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
if !conf.github_ref.starts_with("refs/tags/") {
|
if !is_tag(&conf.github_ref) {
|
||||||
log::error!("GH Releases require a tag");
|
log::error!("GH Releases require a tag");
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
@ -81,4 +85,14 @@ mod tests {
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn is_tag_checks_refs() {
|
||||||
|
for (gitref, expect) in &[
|
||||||
|
("refs/tags/foo", true),
|
||||||
|
("refs/heads/master", false)
|
||||||
|
] {
|
||||||
|
assert_eq!(is_tag(gitref), *expect)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue