summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJérémy Audiger <jeremy.audiger@ioterop.com>2022-03-11 07:36:50 +0000
committerJérémy Audiger <jeremy.audiger@ioterop.com>2022-03-11 07:36:50 +0000
commite765bd484eceead51314ed33e63ff6bf10475f6b (patch)
treed882d973ea5eadf30114bb6222c71a4f638a875b /tests
parent2e9ccf751dddf1f52b4634dc1ef4ed954cf0123e (diff)
chore: add the possibility to keep the prefix from env var.
Diffstat (limited to 'tests')
-rw-r--r--tests/env.rs21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/env.rs b/tests/env.rs
index fcadf81..166a83f 100644
--- a/tests/env.rs
+++ b/tests/env.rs
@@ -75,6 +75,27 @@ fn test_empty_value_is_ignored() {
}
#[test]
+fn test_keep_prefix() {
+ env::set_var("C_A_B", "");
+
+ // Do not keep the prefix
+ let environment = Environment::with_prefix("C");
+
+ assert!(environment.collect().unwrap().contains_key("a_b"));
+
+ let environment = Environment::with_prefix("C").keep_prefix(false);
+
+ assert!(environment.collect().unwrap().contains_key("a_b"));
+
+ // Keep the prefix
+ let environment = Environment::with_prefix("C").keep_prefix(true);
+
+ assert!(environment.collect().unwrap().contains_key("c_a_b"));
+
+ env::remove_var("C_A_B");
+}
+
+#[test]
fn test_custom_separator_behavior() {
env::set_var("C.B.A", "abc");