Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repro for #417 #418

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pathdiff = "0.2"

[dev-dependencies]
serde_derive = "1.0.8"
serde_yaml = "0.9"
float-cmp = "0.9"
chrono = { version = "0.4", features = ["serde"] }
tokio = { version = "1", features = ["rt-multi-thread", "macros", "fs", "io-util", "time"]}
Expand Down
1 change: 1 addition & 0 deletions tests/Settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ place:
# For override tests
FOO: FOO should be overridden
bar: I am bar
192.168.1.1: a string value
31 changes: 31 additions & 0 deletions tests/file_yaml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ struct Settings {
place: Place,
#[serde(rename = "arr")]
elements: Vec<String>,
#[serde(rename = "192.168.1.1")]
ip_key: String,
}

fn make() -> Config {
Expand All @@ -35,6 +37,35 @@ fn make() -> Config {
.unwrap()
}

#[test]
fn test_keys_with_periods_deserialize_serde_yaml() {
let map = "192.168.1.1: a string value";

let c: HashMap<String, String> = serde_yaml::from_str(map).unwrap();

assert_eq!(c.get("192.168.1.1").unwrap(), "a string value");
}

#[test]
fn test_keys_with_periods_deserialize_yaml_rust() {
use yaml_rust::YamlLoader;

let map = "192.168.1.1: a string value";

let c = YamlLoader::load_from_str(map).unwrap().first().unwrap().clone();

assert_eq!(c["192.168.1.1"].as_str().unwrap(), "a string value");
}

#[test]
fn test_keys_with_periods_deserialize() {
let c = make();

let s: Settings = c.try_deserialize().unwrap();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails here because the tests/Settings files are not updated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I guess I was not fully awake when reviewing this. Sorry about that.


assert_eq!(s.ip_key, "a string value");
}

#[test]
fn test_file() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test fails because the files in tests/Settings are not updated for the new key ("192.168.1.1")!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is updated. It fails due to #417

let c = make();
Expand Down