Fix Bug in Asset Server Error Message Formatter (#1340)

This commit is contained in:
Zicklag 2021-01-29 15:26:21 -06:00 committed by GitHub
parent 8e69ff2c2b
commit af67231567
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,7 +30,7 @@ pub enum AssetServerError {
}
fn format_missing_asset_ext(exts: &[String]) -> String {
if exts.is_empty() {
if !exts.is_empty() {
format!(
" for the following extension{}: {}",
if exts.len() > 1 { "s" } else { "" },
@ -572,6 +572,28 @@ mod test {
)
}
#[test]
fn missing_asset_loader_error_messages() {
assert_eq!(
AssetServerError::MissingAssetLoader { extensions: vec![] }.to_string(),
"no `AssetLoader` found"
);
assert_eq!(
AssetServerError::MissingAssetLoader {
extensions: vec!["png".into()]
}
.to_string(),
"no `AssetLoader` found for the following extension: png"
);
assert_eq!(
AssetServerError::MissingAssetLoader {
extensions: vec!["1.2.png".into(), "2.png".into(), "png".into()]
}
.to_string(),
"no `AssetLoader` found for the following extensions: 1.2.png, 2.png, png"
);
}
#[test]
fn filename_with_dots() {
let asset_server = setup();