From e765bd484eceead51314ed33e63ff6bf10475f6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Audiger?= Date: Fri, 11 Mar 2022 07:36:50 +0000 Subject: chore: add the possibility to keep the prefix from env var. --- tests/env.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'tests') diff --git a/tests/env.rs b/tests/env.rs index fcadf81..166a83f 100644 --- a/tests/env.rs +++ b/tests/env.rs @@ -74,6 +74,27 @@ fn test_empty_value_is_ignored() { env::remove_var("C_A_B"); } +#[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"); -- cgit v1.2.3