Skip to content

Commit d0b7c94

Browse files
committed
Add a test that demonstrates the panic behavior
1 parent 9e62af6 commit d0b7c94

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

fluent-fallback/tests/localization_test.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,3 +488,23 @@ async fn localization_handle_state_changes_mid_async() {
488488

489489
bundles.format_value("key", None, &mut errors).await;
490490
}
491+
492+
#[test]
493+
#[should_panic]
494+
fn localization_duplicate_resources() {
495+
let resource_ids: Vec<ResourceId> =
496+
vec!["test.ftl".into(), "test2.ftl".into(), "test2.ftl".into()];
497+
let locales = Locales::new(vec![langid!("pl"), langid!("en-US")]);
498+
let res_mgr = ResourceManager;
499+
let mut errors = vec![];
500+
501+
let loc = Localization::with_env(resource_ids, true, locales, res_mgr);
502+
let bundles = loc.bundles();
503+
504+
let value = bundles
505+
.format_value_sync("hello-world", None, &mut errors)
506+
.unwrap();
507+
assert_eq!(value, Some(Cow::Borrowed("Hello World [pl]")));
508+
509+
assert_eq!(errors.len(), 0, "There were no errors");
510+
}

0 commit comments

Comments
 (0)