use super::*;
#[test]
fn anonymous_read_is_closed_unless_it_is_asked_for() {
assert!(!anonymous_read(None), "unset must not open it");
for refused in ["false", "", "1", "yes", "True", "TRUE", " true", "true "] {
assert!(
!anonymous_read(Some(refused)),
"{refused:?} is not the string that opens it"
);
}
assert!(anonymous_read(Some("true")), "the one value that opens it");
}
#[test]
fn forgejo_and_gitea_are_the_same_forge() {
assert_eq!(provider(Some("gitea")), Provider::Gitea);
assert_eq!(
provider(Some("forgejo")),
Provider::Gitea,
"Forgejo is a fork of Gitea and answers the same API, so naming either has to work"
);
assert_eq!(provider(Some("gitlab")), Provider::Gitlab);
for github in [None, Some("github"), Some("Gitea"), Some("nonsense")] {
assert_eq!(provider(github), Provider::Github, "{github:?}");
}
}
#[test]
fn an_api_root_keeps_no_trailing_slash() {
assert_eq!(
api_url(Provider::Gitea, Some("https://git.example.com/api/v1/")),
"https://git.example.com/api/v1"
);
assert_eq!(
api_url(Provider::Github, None),
"https://api.github.com",
"an unset variable still falls back to the default for a forge that has one"
);
}
#[test]
#[should_panic(expected = "LFSX_GITEA_API_URL must be set")]
fn a_self_hosted_forge_refuses_to_start_without_its_api_root() {
api_url(Provider::Gitea, None);
}