File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ extern crate log;
3
3
4
4
#[ macro_use]
5
5
extern crate serde_derive;
6
+ extern crate serde_json;
6
7
7
8
use config:: * ;
8
9
@@ -26,3 +27,26 @@ fn test_load_level_uppercase() {
26
27
assert_eq ! ( l, log:: Level :: Error ) ;
27
28
}
28
29
30
+ #[ test]
31
+ fn test_load_level_lowercase ( ) {
32
+ // to verify that this works
33
+ {
34
+ use std:: str:: FromStr ;
35
+ let l = log:: Level :: from_str ( "error" ) . unwrap ( ) ;
36
+ assert_eq ! ( l, log:: Level :: Error ) ;
37
+ }
38
+
39
+ let s = r#"{ "log": "error" }"# ;
40
+
41
+ // to confirm serde_json works as expected
42
+ {
43
+ let j: Settings = serde_json:: from_str ( s) . unwrap ( ) ;
44
+ assert_eq ! ( j. log, log:: Level :: Error ) ;
45
+ }
46
+
47
+ let c = config ( s) ;
48
+ assert_eq ! ( c. get_str( "log" ) . unwrap( ) , "error" ) ;
49
+ let l = c. get :: < log:: Level > ( "log" ) ;
50
+ assert ! ( l. is_ok( ) , "Expected Ok(_) for {:?}" , l) ;
51
+ assert_eq ! ( l. unwrap( ) , log:: Level :: Error ) ;
52
+ }
You can’t perform that action at this time.
0 commit comments