summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Beyer <mail@beyermatthias.de>2023-02-02 08:48:16 +0100
committerMatthias Beyer <mail@beyermatthias.de>2023-02-02 08:51:34 +0100
commit53c8008d04171d9746f6af5d293b2eee317f24fc (patch)
treedc362b84870fbd83977048a13ea00c04806f2be9
parent88fe5b032517b7e7ed731de67a7191bfa896bafe (diff)
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 <mail@beyermatthias.de>
-rw-r--r--tests/errors.rs13
-rw-r--r--tests/file_toml.rs15
-rw-r--r--tests/legacy/errors.rs17
-rw-r--r--tests/legacy/file_toml.rs18
4 files changed, 8 insertions, 55 deletions
diff --git a/tests/errors.rs b/tests/errors.rs
index 04e04a6..1822bff 100644
--- a/tests/errors.rs
+++ b/tests/errors.rs
@@ -19,16 +19,11 @@ fn test_error_parse() {
.add_source(File::new("tests/Settings-invalid", FileFormat::Toml))
.build();
- let path: PathBuf = ["tests", "Settings-invalid.toml"].iter().collect();
-
assert!(res.is_err());
- assert_eq!(
- res.unwrap_err().to_string(),
- format!(
- "invalid TOML value, did you mean to use a quoted string? at line 2 column 9 in {}",
- path.display()
- )
- );
+ assert!(res
+ .unwrap_err()
+ .to_string()
+ .contains("TOML parse error at line 2, column 9"));
}
#[test]
diff --git a/tests/file_toml.rs b/tests/file_toml.rs
index 6ab1a2c..e0ec626 100644
--- a/tests/file_toml.rs
+++ b/tests/file_toml.rs
@@ -2,8 +2,6 @@
use serde_derive::Deserialize;
-use std::path::PathBuf;
-
use config::{Config, File, FileFormat, Map, Value};
use float_cmp::ApproxEqUlps;
@@ -90,16 +88,11 @@ fn test_error_parse() {
.add_source(File::new("tests/Settings-invalid", FileFormat::Toml))
.build();
- let path_with_extension: PathBuf = ["tests", "Settings-invalid.toml"].iter().collect();
-
assert!(res.is_err());
- assert_eq!(
- res.unwrap_err().to_string(),
- format!(
- "invalid TOML value, did you mean to use a quoted string? at line 2 column 9 in {}",
- path_with_extension.display()
- )
- );
+ assert!(res
+ .unwrap_err()
+ .to_string()
+ .contains("TOML parse error at line 2, column 9"));
}
#[derive(Debug, Deserialize, PartialEq)]
diff --git a/tests/legacy/errors.rs b/tests/legacy/errors.rs
index e0835f5..191e85e 100644
--- a/tests/legacy/errors.rs
+++ b/tests/legacy/errors.rs
@@ -15,23 +15,6 @@ fn make() -> Config {
}
#[test]
-fn test_error_parse() {
- let mut c = Config::default();
- let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Toml));
-
- let path: PathBuf = ["tests", "Settings-invalid.toml"].iter().collect();
-
- assert!(res.is_err());
- assert_eq!(
- res.unwrap_err().to_string(),
- format!(
- "invalid TOML value, did you mean to use a quoted string? at line 2 column 9 in {}",
- path.display()
- )
- );
-}
-
-#[test]
fn test_error_type() {
let c = make();
diff --git a/tests/legacy/file_toml.rs b/tests/legacy/file_toml.rs
index 5d7a9e3..2ecdb01 100644
--- a/tests/legacy/file_toml.rs
+++ b/tests/legacy/file_toml.rs
@@ -1,7 +1,6 @@
#![cfg(feature = "toml")]
use serde_derive::Deserialize;
-use std::path::PathBuf;
use config::{Config, File, FileFormat, Map, Value};
use float_cmp::ApproxEqUlps;
@@ -83,20 +82,3 @@ fn test_file() {
);
}
}
-
-#[test]
-fn test_error_parse() {
- let mut c = Config::default();
- let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Toml));
-
- let path_with_extension: PathBuf = ["tests", "Settings-invalid.toml"].iter().collect();
-
- assert!(res.is_err());
- assert_eq!(
- res.unwrap_err().to_string(),
- format!(
- "invalid TOML value, did you mean to use a quoted string? at line 2 column 9 in {}",
- path_with_extension.display()
- )
- );
-}