From c06d546ae78154eaa1777466a7e5c32a48fca693 Mon Sep 17 00:00:00 2001 From: phoenix Date: Fri, 10 Oct 2025 14:11:01 -0400 Subject: [PATCH] Updated test --- src/utility.rs | 7 +++++++ tests/test.rs | 11 ++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 src/utility.rs diff --git a/src/utility.rs b/src/utility.rs new file mode 100644 index 0000000..0c749f0 --- /dev/null +++ b/src/utility.rs @@ -0,0 +1,7 @@ +pub fn split_words(var: &crate::EnvVar) -> Result, std::io::Error> { + if var.has_delimiter { + Ok(var.value.split(var.delimiter).map(|c| c.parse::().unwrap()).collect()) + } else { + Err(std::io::Error::other("Environment variable does not have a delimiter")) + } +} diff --git a/tests/test.rs b/tests/test.rs index 62f23ed..c09967e 100644 --- a/tests/test.rs +++ b/tests/test.rs @@ -116,7 +116,16 @@ mod tests { result ); - assert_eq!(result.has_delimiter, true, "The {} variable has an issue finding the delimiter", result.key) + assert_eq!(result.has_delimiter, true, "The {} variable has an issue finding the delimiter", result.key); + + match icarus_envy::utility::split_words(&result) { + Ok(allowed_origins) => { + assert_eq!(allowed_origins.len(), 2, "The amount of allowed origins does not match. {} {}", allowed_origins.len(), 2) + } + Err(err) => { + assert!(false, "Error: {:?}", err) + } + } } #[test]