Skip to content

Commit 3ecc24a

Browse files
committed
Rewrite test with TOML, as module is only compiled with "toml" feature enabled
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
1 parent 1f06a0f commit 3ecc24a

File tree

2 files changed

+9
-16
lines changed

2 files changed

+9
-16
lines changed

tests/errors.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,17 @@ fn error_with_path() {
117117
inner: Inner,
118118
}
119119
const CFG: &str = r#"
120-
inner:
121-
test: ABC
122-
"#;
120+
inner.test = "ABC"
121+
"#;
123122

124123
let e = Config::builder()
125-
.add_source(File::from_str(CFG, FileFormat::Yaml))
124+
.add_source(File::from_str(CFG, FileFormat::Toml))
126125
.build()
127126
.unwrap()
128127
.try_into::<Outer>()
129128
.unwrap_err();
130129

131-
if let ConfigError::Type {
132-
key: Some(path), ..
133-
} = e
134-
{
130+
if let ConfigError::Type { key: Some(path), .. } = e {
135131
assert_eq!(path, "inner.test");
136132
} else {
137133
panic!("Wrong error {:?}", e);

tests/legacy/errors.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,15 @@ fn error_with_path() {
113113
struct Outer {
114114
inner: Inner,
115115
}
116+
116117
const CFG: &str = r#"
117-
inner:
118-
test: ABC
119-
"#;
118+
inner.test = "ABC"
119+
"#;
120120

121121
let mut cfg = Config::default();
122-
cfg.merge(File::from_str(CFG, FileFormat::Yaml)).unwrap();
122+
cfg.merge(File::from_str(CFG, FileFormat::Toml)).unwrap();
123123
let e = cfg.try_into::<Outer>().unwrap_err();
124-
if let ConfigError::Type {
125-
key: Some(path), ..
126-
} = e
127-
{
124+
if let ConfigError::Type { key: Some(path), .. } = e {
128125
assert_eq!(path, "inner.test");
129126
} else {
130127
panic!("Wrong error {:?}", e);

0 commit comments

Comments
 (0)