2022-12-27 20:16:18 -08:00
|
|
|
use {
|
|
|
|
executable_path::executable_path,
|
|
|
|
std::{process::Command, str},
|
|
|
|
};
|
2021-06-01 16:37:40 -07:00
|
|
|
|
|
|
|
fn stdout(reference: &str) -> String {
|
2021-07-03 21:16:24 -07:00
|
|
|
let output = Command::new(executable_path("ref-type"))
|
2022-11-22 16:36:23 -08:00
|
|
|
.args(["--reference", reference])
|
2021-06-01 16:37:40 -07:00
|
|
|
.output()
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert!(output.status.success());
|
|
|
|
|
|
|
|
String::from_utf8(output.stdout).unwrap()
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-07-03 21:16:24 -07:00
|
|
|
fn junk_is_other() {
|
2024-01-24 15:37:26 -08:00
|
|
|
assert_eq!(stdout("refs/tags/asdf"), "value=other\n");
|
2021-06-01 16:37:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-07-03 21:16:24 -07:00
|
|
|
fn valid_version_is_release() {
|
2024-01-24 15:37:26 -08:00
|
|
|
assert_eq!(stdout("refs/tags/0.0.0"), "value=release\n");
|
2021-06-01 16:37:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-07-03 21:16:24 -07:00
|
|
|
fn valid_version_with_trailing_characters_is_other() {
|
2024-01-24 15:37:26 -08:00
|
|
|
assert_eq!(stdout("refs/tags/0.0.0-rc1"), "value=other\n");
|
2021-06-01 16:37:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
2021-07-03 21:16:24 -07:00
|
|
|
fn valid_version_with_lots_of_digits_is_release() {
|
2021-06-01 16:37:40 -07:00
|
|
|
assert_eq!(
|
|
|
|
stdout("refs/tags/01232132.098327498374.43268473849734"),
|
2024-01-24 15:37:26 -08:00
|
|
|
"value=release\n"
|
2021-06-01 16:37:40 -07:00
|
|
|
);
|
|
|
|
}
|