Skip to content

Commit 53c8008

Browse files
committed
Fix test for error string
This patch fixes the error test for parsing invalid TOML. When we updated toml-rs to 0.7.0, the error display string was altered. Thus we had to adapt the tests for that string. The legacy tests were removed as they are equal to the "non-legacy" tests. No need to keep them both. Signed-off-by: Matthias Beyer <[email protected]>
1 parent 88fe5b0 commit 53c8008

File tree

4 files changed

+8
-55
lines changed

4 files changed

+8
-55
lines changed

tests/errors.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,11 @@ fn test_error_parse() {
1919
.add_source(File::new("tests/Settings-invalid", FileFormat::Toml))
2020
.build();
2121

22-
let path: PathBuf = ["tests", "Settings-invalid.toml"].iter().collect();
23-
2422
assert!(res.is_err());
25-
assert_eq!(
26-
res.unwrap_err().to_string(),
27-
format!(
28-
"invalid TOML value, did you mean to use a quoted string? at line 2 column 9 in {}",
29-
path.display()
30-
)
31-
);
23+
assert!(res
24+
.unwrap_err()
25+
.to_string()
26+
.contains("TOML parse error at line 2, column 9"));
3227
}
3328

3429
#[test]

tests/file_toml.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
use serde_derive::Deserialize;
44

5-
use std::path::PathBuf;
6-
75
use config::{Config, File, FileFormat, Map, Value};
86
use float_cmp::ApproxEqUlps;
97

@@ -90,16 +88,11 @@ fn test_error_parse() {
9088
.add_source(File::new("tests/Settings-invalid", FileFormat::Toml))
9189
.build();
9290

93-
let path_with_extension: PathBuf = ["tests", "Settings-invalid.toml"].iter().collect();
94-
9591
assert!(res.is_err());
96-
assert_eq!(
97-
res.unwrap_err().to_string(),
98-
format!(
99-
"invalid TOML value, did you mean to use a quoted string? at line 2 column 9 in {}",
100-
path_with_extension.display()
101-
)
102-
);
92+
assert!(res
93+
.unwrap_err()
94+
.to_string()
95+
.contains("TOML parse error at line 2, column 9"));
10396
}
10497

10598
#[derive(Debug, Deserialize, PartialEq)]

tests/legacy/errors.rs

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,6 @@ fn make() -> Config {
1414
c
1515
}
1616

17-
#[test]
18-
fn test_error_parse() {
19-
let mut c = Config::default();
20-
let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Toml));
21-
22-
let path: PathBuf = ["tests", "Settings-invalid.toml"].iter().collect();
23-
24-
assert!(res.is_err());
25-
assert_eq!(
26-
res.unwrap_err().to_string(),
27-
format!(
28-
"invalid TOML value, did you mean to use a quoted string? at line 2 column 9 in {}",
29-
path.display()
30-
)
31-
);
32-
}
33-
3417
#[test]
3518
fn test_error_type() {
3619
let c = make();

tests/legacy/file_toml.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#![cfg(feature = "toml")]
22

33
use serde_derive::Deserialize;
4-
use std::path::PathBuf;
54

65
use config::{Config, File, FileFormat, Map, Value};
76
use float_cmp::ApproxEqUlps;
@@ -83,20 +82,3 @@ fn test_file() {
8382
);
8483
}
8584
}
86-
87-
#[test]
88-
fn test_error_parse() {
89-
let mut c = Config::default();
90-
let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Toml));
91-
92-
let path_with_extension: PathBuf = ["tests", "Settings-invalid.toml"].iter().collect();
93-
94-
assert!(res.is_err());
95-
assert_eq!(
96-
res.unwrap_err().to_string(),
97-
format!(
98-
"invalid TOML value, did you mean to use a quoted string? at line 2 column 9 in {}",
99-
path_with_extension.display()
100-
)
101-
);
102-
}

0 commit comments

Comments
 (0)