test for is_tag

This commit is contained in:
softprops 2019-08-25 02:23:48 -04:00
parent ca44db83d6
commit 970096b3d4

View file

@ -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(
conf: Config,
releaser: &dyn Releaser,
uploader: &dyn AssetUploader,
) -> 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");
return Ok(());
}
@ -81,4 +85,14 @@ mod tests {
}
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)
}
}
}