summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRyan Leckey <leckey.ryan@gmail.com>2017-07-30 13:20:36 -0700
committerRyan Leckey <leckey.ryan@gmail.com>2017-07-30 13:20:36 -0700
commit14224be23dc2f253a240b85214927d97e1160669 (patch)
tree6f5b02b26aef5cf37bb14f32b9048165b67109ce /tests
parent71f4b182d1e56febda64bd620ae0e0f65de333cd (diff)
Remove ConfigResult; close #36
Diffstat (limited to 'tests')
-rw-r--r--tests/datetime.rs5
-rw-r--r--tests/errors.rs21
-rw-r--r--tests/file.rs21
-rw-r--r--tests/file_json.rs12
-rw-r--r--tests/file_toml.rs12
-rw-r--r--tests/file_yaml.rs14
-rw-r--r--tests/get.rs22
-rw-r--r--tests/merge.rs5
-rw-r--r--tests/set.rs3
9 files changed, 79 insertions, 36 deletions
diff --git a/tests/datetime.rs b/tests/datetime.rs
index f2dc9fe..8a50c01 100644
--- a/tests/datetime.rs
+++ b/tests/datetime.rs
@@ -2,7 +2,7 @@ extern crate config;
extern crate chrono;
use config::*;
-use chrono::{DateTime, Utc, TimeZone};
+use chrono::{DateTime, TimeZone, Utc};
fn make() -> Config {
Config::default()
@@ -14,12 +14,14 @@ fn make() -> Config {
"#,
FileFormat::Json,
))
+ .unwrap()
.merge(File::from_str(
r#"
yaml_datetime: 2017-06-12T10:58:30Z
"#,
FileFormat::Yaml,
))
+ .unwrap()
.merge(File::from_str(
r#"
toml_datetime = 2017-05-11T14:55:15Z
@@ -27,6 +29,7 @@ fn make() -> Config {
FileFormat::Toml,
))
.unwrap()
+ .clone()
}
#[test]
diff --git a/tests/errors.rs b/tests/errors.rs
index 835ead1..77a58ab 100644
--- a/tests/errors.rs
+++ b/tests/errors.rs
@@ -16,8 +16,10 @@ fn test_error_parse() {
let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Toml));
assert!(res.is_err());
- assert_eq!(res.unwrap_err().to_string(),
- "invalid number at line 2 in tests/Settings-invalid.toml".to_string());
+ assert_eq!(
+ res.unwrap_err().to_string(),
+ "invalid number at line 2 in tests/Settings-invalid.toml".to_string()
+ );
}
#[test]
@@ -27,9 +29,12 @@ fn test_error_type() {
let res = c.get::<bool>("boolean_s_parse");
assert!(res.is_err());
- assert_eq!(res.unwrap_err().to_string(),
- "invalid type: string \"fals\", expected a boolean for key `boolean_s_parse` in tests/Settings.toml"
- .to_string());
+ assert_eq!(
+ res.unwrap_err().to_string(),
+ "invalid type: string \"fals\", expected a boolean for key \
+ `boolean_s_parse` in tests/Settings.toml"
+ .to_string()
+ );
}
#[test]
@@ -40,6 +45,8 @@ fn test_error_type_detached() {
let res = value.try_into::<bool>();
assert!(res.is_err());
- assert_eq!(res.unwrap_err().to_string(),
- "invalid type: string \"fals\", expected a boolean".to_string());
+ assert_eq!(
+ res.unwrap_err().to_string(),
+ "invalid type: string \"fals\", expected a boolean".to_string()
+ );
}
diff --git a/tests/file.rs b/tests/file.rs
index 04a7361..5f49e7f 100644
--- a/tests/file.rs
+++ b/tests/file.rs
@@ -5,7 +5,9 @@ use config::*;
#[test]
fn test_file_not_required() {
let mut c = Config::default();
- let res = c.merge(File::new("tests/NoSettings", FileFormat::Yaml).required(false));
+ let res = c.merge(
+ File::new("tests/NoSettings", FileFormat::Yaml).required(false),
+ );
assert!(res.is_ok());
}
@@ -16,15 +18,17 @@ fn test_file_required_not_found() {
let res = c.merge(File::new("tests/NoSettings", FileFormat::Yaml));
assert!(res.is_err());
- assert_eq!(res.unwrap_err().to_string(),
- "configuration file \"tests/NoSettings\" not found"
- .to_string());
+ assert_eq!(
+ res.unwrap_err().to_string(),
+ "configuration file \"tests/NoSettings\" not found".to_string()
+ );
}
#[test]
fn test_file_auto() {
let mut c = Config::default();
- c.merge(File::with_name("tests/Settings-production")).unwrap();
+ c.merge(File::with_name("tests/Settings-production"))
+ .unwrap();
assert_eq!(c.get("debug").ok(), Some(false));
assert_eq!(c.get("production").ok(), Some(true));
@@ -36,9 +40,10 @@ fn test_file_auto_not_found() {
let res = c.merge(File::with_name("tests/NoSettings"));
assert!(res.is_err());
- assert_eq!(res.unwrap_err().to_string(),
- "configuration file \"tests/NoSettings\" not found"
- .to_string());
+ assert_eq!(
+ res.unwrap_err().to_string(),
+ "configuration file \"tests/NoSettings\" not found".to_string()
+ );
}
#[test]
diff --git a/tests/file_json.rs b/tests/file_json.rs
index 983be86..1d35cae 100644
--- a/tests/file_json.rs
+++ b/tests/file_json.rs
@@ -56,7 +56,10 @@ fn test_file() {
assert_eq!(s.place.telephone, None);
assert_eq!(s.elements.len(), 10);
assert_eq!(s.elements[3], "4".to_string());
- assert_eq!(s.place.creator["name"].clone().into_str().unwrap(), "John Smith".to_string());
+ assert_eq!(
+ s.place.creator["name"].clone().into_str().unwrap(),
+ "John Smith".to_string()
+ );
}
#[test]
@@ -65,7 +68,8 @@ fn test_error_parse() {
let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Json));
assert!(res.is_err());
- assert_eq!(res.unwrap_err().to_string(),
- "expected `:` at line 4 column 1 in tests/Settings-invalid.json"
- .to_string());
+ assert_eq!(
+ res.unwrap_err().to_string(),
+ "expected `:` at line 4 column 1 in tests/Settings-invalid.json".to_string()
+ );
}
diff --git a/tests/file_toml.rs b/tests/file_toml.rs
index a46e808..f272698 100644
--- a/tests/file_toml.rs
+++ b/tests/file_toml.rs
@@ -56,7 +56,10 @@ fn test_file() {
assert_eq!(s.place.telephone, None);
assert_eq!(s.elements.len(), 10);
assert_eq!(s.elements[3], "4".to_string());
- assert_eq!(s.place.creator["name"].clone().into_str().unwrap(), "John Smith".to_string());
+ assert_eq!(
+ s.place.creator["name"].clone().into_str().unwrap(),
+ "John Smith".to_string()
+ );
}
#[test]
@@ -65,7 +68,8 @@ fn test_error_parse() {
let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Toml));
assert!(res.is_err());
- assert_eq!(res.unwrap_err().to_string(),
- "invalid number at line 2 in tests/Settings-invalid.toml"
- .to_string());
+ assert_eq!(
+ res.unwrap_err().to_string(),
+ "invalid number at line 2 in tests/Settings-invalid.toml".to_string()
+ );
}
diff --git a/tests/file_yaml.rs b/tests/file_yaml.rs
index 4ca5557..529a8e4 100644
--- a/tests/file_yaml.rs
+++ b/tests/file_yaml.rs
@@ -56,7 +56,10 @@ fn test_file() {
assert_eq!(s.place.telephone, None);
assert_eq!(s.elements.len(), 10);
assert_eq!(s.elements[3], "4".to_string());
- assert_eq!(s.place.creator["name"].clone().into_str().unwrap(), "John Smith".to_string());
+ assert_eq!(
+ s.place.creator["name"].clone().into_str().unwrap(),
+ "John Smith".to_string()
+ );
}
#[test]
@@ -65,7 +68,10 @@ fn test_error_parse() {
let res = c.merge(File::new("tests/Settings-invalid", FileFormat::Yaml));
assert!(res.is_err());
- assert_eq!(res.unwrap_err().to_string(),
- "while parsing a block mapping, did not find expected key at line 2 column 1 in tests/Settings-invalid.yaml"
- .to_string());
+ assert_eq!(
+ res.unwrap_err().to_string(),
+ "while parsing a block mapping, did not find expected key at \
+ line 2 column 1 in tests/Settings-invalid.yaml"
+ .to_string()
+ );
}
diff --git a/tests/get.rs b/tests/get.rs
index 1922fca..995f73c 100644
--- a/tests/get.rs
+++ b/tests/get.rs
@@ -41,9 +41,10 @@ fn test_not_found() {
let res = c.get::<bool>("not_found");
assert!(res.is_err());
- assert_eq!(res.unwrap_err().to_string(),
- "configuration property \"not_found\" not found"
- .to_string());
+ assert_eq!(
+ res.unwrap_err().to_string(),
+ "configuration property \"not_found\" not found".to_string()
+ );
}
#[test]
@@ -84,7 +85,10 @@ fn test_get_scalar_path() {
let c = make();
assert_eq!(c.get("place.favorite").ok(), Some(false));
- assert_eq!(c.get("place.creator.name").ok(), Some("John Smith".to_string()));
+ assert_eq!(
+ c.get("place.creator.name").ok(),
+ Some("John Smith".to_string())
+ );
}
#[test]
@@ -104,7 +108,10 @@ fn test_map() {
let m: HashMap<String, Value> = c.get("place").unwrap();
assert_eq!(m.len(), 7);
- assert_eq!(m["name"].clone().into_str().unwrap(), "Torre di Pisa".to_string());
+ assert_eq!(
+ m["name"].clone().into_str().unwrap(),
+ "Torre di Pisa".to_string()
+ );
assert_eq!(m["reviews"].clone().into_int().unwrap(), 3866);
}
@@ -128,7 +135,10 @@ fn test_map_struct() {
let s: Settings = c.deserialize().unwrap();
assert_eq!(s.place.len(), 7);
- assert_eq!(s.place["name"].clone().into_str().unwrap(), "Torre di Pisa".to_string());
+ assert_eq!(
+ s.place["name"].clone().into_str().unwrap(),
+ "Torre di Pisa".to_string()
+ );
assert_eq!(s.place["reviews"].clone().into_int().unwrap(), 3866);
}
diff --git a/tests/merge.rs b/tests/merge.rs
index 4a42d6a..f83eef8 100644
--- a/tests/merge.rs
+++ b/tests/merge.rs
@@ -19,6 +19,9 @@ fn test_merge() {
assert_eq!(c.get("debug").ok(), Some(false));
assert_eq!(c.get("production").ok(), Some(true));
- assert_eq!(c.get("place.creator.name").ok(), Some("Somebody New".to_string()));
+ assert_eq!(
+ c.get("place.creator.name").ok(),
+ Some("Somebody New".to_string())
+ );
assert_eq!(c.get("place.rating").ok(), Some(4.9));
}
diff --git a/tests/set.rs b/tests/set.rs
index 14ddfae..0b0f1a3 100644
--- a/tests/set.rs
+++ b/tests/set.rs
@@ -61,7 +61,8 @@ fn test_set_capital() {
c.set_default("tHiS", false).unwrap();
c.set("THAT", true).unwrap();
- c.merge(File::from_str("{\"loGleVel\": 5}", FileFormat::Json)).unwrap();
+ c.merge(File::from_str("{\"loGleVel\": 5}", FileFormat::Json))
+ .unwrap();
assert_eq!(c.get("this").ok(), Some(false));
assert_eq!(c.get("ThIs").ok(), Some(false));