Code formatting
Some checks failed
Release Tagging / release (pull_request) Successful in 32s
Rust Build / Check (pull_request) Successful in 31s
Rust Build / Test Suite (pull_request) Successful in 32s
Rust Build / Rustfmt (pull_request) Successful in 32s
Rust Build / Clippy (pull_request) Failing after 33s
Rust Build / build (pull_request) Successful in 35s

This commit is contained in:
2025-10-10 14:25:13 -04:00
parent 797430c9d2
commit 101547dbf4
3 changed files with 21 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ pub struct EnvVar {
pub key: String, pub key: String,
pub value: String, pub value: String,
pub has_delimiter: bool, pub has_delimiter: bool,
pub delimiter: char pub delimiter: char,
} }
pub fn init_envvar(key: &str, value: &str) -> EnvVar { pub fn init_envvar(key: &str, value: &str) -> EnvVar {

View File

@@ -2,8 +2,14 @@
/// extract it into some strings /// extract it into some strings
pub fn delimitize(var: &crate::EnvVar) -> Result<Vec<String>, std::io::Error> { pub fn delimitize(var: &crate::EnvVar) -> Result<Vec<String>, std::io::Error> {
if var.has_delimiter { if var.has_delimiter {
Ok(var.value.split(var.delimiter).map(|c| c.parse::<String>().unwrap()).collect()) Ok(var
.value
.split(var.delimiter)
.map(|c| c.parse::<String>().unwrap())
.collect())
} else { } else {
Err(std::io::Error::other("Environment variable does not have a delimiter")) Err(std::io::Error::other(
"Environment variable does not have a delimiter",
))
} }
} }

View File

@@ -116,11 +116,21 @@ mod tests {
result 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::delimitize(&result) { match icarus_envy::utility::delimitize(&result) {
Ok(allowed_origins) => { Ok(allowed_origins) => {
assert_eq!(allowed_origins.len(), 2, "The amount of allowed origins does not match. {} {}", allowed_origins.len(), 2) assert_eq!(
allowed_origins.len(),
2,
"The amount of allowed origins does not match. {} {}",
allowed_origins.len(),
2
)
} }
Err(err) => { Err(err) => {
assert!(false, "Error: {:?}", err) assert!(false, "Error: {:?}", err)