Skip to content

Commit

Permalink
Fix Bug in Asset Server Error Message Formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
zicklag committed Jan 29, 2021
1 parent cc9ed52 commit 76db027
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion crates/bevy_asset/src/asset_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 { "" },
Expand Down Expand Up @@ -572,6 +572,35 @@ mod test {
)
}

#[test]
fn missing_asset_loader_error_messages() {
assert_eq!(
format!(
"{}",
AssetServerError::MissingAssetLoader { extensions: vec![] }
),
"no `AssetLoader` found"
);
assert_eq!(
format!(
"{}",
AssetServerError::MissingAssetLoader {
extensions: vec!["png".into()]
}
),
"no `AssetLoader` found for the following extension: png"
);
assert_eq!(
format!(
"{}",
AssetServerError::MissingAssetLoader {
extensions: vec!["1.2.png".into(), "2.png".into(), "png".into()]
}
),
"no `AssetLoader` found for the following extensions: 1.2.png, 2.png, png"
);
}

#[test]
fn filename_with_dots() {
let asset_server = setup();
Expand Down

0 comments on commit 76db027

Please sign in to comment.