Skip to content

Commit

Permalink
Adds failing test demonstrating env parsing bug
Browse files Browse the repository at this point in the history
  • Loading branch information
scottopell committed Dec 22, 2023
1 parent 68b3d37 commit 63c67e3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lading/src/bin/lading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ struct CliKeyValues {
inner: FxHashMap<String, String>,
}

impl CliKeyValues {
fn get(&self, key: &str) -> Option<&str> {
self.inner.get(key).map(|s| s.as_str())
}
}

impl Display for CliKeyValues {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> Result<(), fmt::Error> {
for (k, v) in self.inner.iter() {
Expand Down Expand Up @@ -596,4 +602,15 @@ generator: []
let deser = deser.unwrap().to_string();
assert_eq!(deser, "first=one,");
}

#[test]
fn cli_key_values_deserializes_kv_comma_separated_value() {
let val = "DD_API_KEY=00000001,DD_TELEMETRY_ENABLED=true,DD_TAGS=uqhwd:b2xiyw,hf9gy:uwcy04";
let deser = CliKeyValues::from_str(val);
let deser = deser.unwrap();

assert_eq!(deser.get("DD_API_KEY").unwrap(), "00000001");
assert_eq!(deser.get("DD_TELEMETRY_ENABLED").unwrap(), "true");
assert_eq!(deser.get("DD_TAGS").unwrap(), "uqhwd:b2xiyw,hf9gy:uwcy04");
}
}

0 comments on commit 63c67e3

Please sign in to comment.