Skip to content

Commit af67231

Browse files
authored
Fix Bug in Asset Server Error Message Formatter (#1340)
1 parent 8e69ff2 commit af67231

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

crates/bevy_asset/src/asset_server.rs

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub enum AssetServerError {
3030
}
3131

3232
fn format_missing_asset_ext(exts: &[String]) -> String {
33-
if exts.is_empty() {
33+
if !exts.is_empty() {
3434
format!(
3535
" for the following extension{}: {}",
3636
if exts.len() > 1 { "s" } else { "" },
@@ -572,6 +572,28 @@ mod test {
572572
)
573573
}
574574

575+
#[test]
576+
fn missing_asset_loader_error_messages() {
577+
assert_eq!(
578+
AssetServerError::MissingAssetLoader { extensions: vec![] }.to_string(),
579+
"no `AssetLoader` found"
580+
);
581+
assert_eq!(
582+
AssetServerError::MissingAssetLoader {
583+
extensions: vec!["png".into()]
584+
}
585+
.to_string(),
586+
"no `AssetLoader` found for the following extension: png"
587+
);
588+
assert_eq!(
589+
AssetServerError::MissingAssetLoader {
590+
extensions: vec!["1.2.png".into(), "2.png".into(), "png".into()]
591+
}
592+
.to_string(),
593+
"no `AssetLoader` found for the following extensions: 1.2.png, 2.png, png"
594+
);
595+
}
596+
575597
#[test]
576598
fn filename_with_dots() {
577599
let asset_server = setup();

0 commit comments

Comments
 (0)