@@ -6,16 +6,18 @@ use config::*;
6
6
7
7
#[ test]
8
8
fn test_file_not_required ( ) {
9
- let mut c = Config :: default ( ) ;
10
- let res = c. merge ( File :: new ( "tests/NoSettings" , FileFormat :: Yaml ) . required ( false ) ) ;
9
+ let mut c = Config :: builder ( ) ;
10
+ c. add_source ( File :: new ( "tests/NoSettings" , FileFormat :: Yaml ) . required ( false ) ) ;
11
+ let res = c. build ( ) ;
11
12
12
13
assert ! ( res. is_ok( ) ) ;
13
14
}
14
15
15
16
#[ test]
16
17
fn test_file_required_not_found ( ) {
17
- let mut c = Config :: default ( ) ;
18
- let res = c. merge ( File :: new ( "tests/NoSettings" , FileFormat :: Yaml ) ) ;
18
+ let mut c = Config :: builder ( ) ;
19
+ c. add_source ( File :: new ( "tests/NoSettings" , FileFormat :: Yaml ) ) ;
20
+ let res = c. build ( ) ;
19
21
20
22
assert ! ( res. is_err( ) ) ;
21
23
assert_eq ! (
@@ -26,18 +28,20 @@ fn test_file_required_not_found() {
26
28
27
29
#[ test]
28
30
fn test_file_auto ( ) {
29
- let mut c = Config :: default ( ) ;
30
- c. merge ( File :: with_name ( "tests/Settings-production" ) )
31
- . unwrap ( ) ;
31
+ let mut builder = Config :: builder ( ) ;
32
+ builder. add_source ( File :: with_name ( "tests/Settings-production" ) ) ;
33
+
34
+ let c = builder. build ( ) . unwrap ( ) ;
32
35
33
36
assert_eq ! ( c. get( "debug" ) . ok( ) , Some ( false ) ) ;
34
37
assert_eq ! ( c. get( "production" ) . ok( ) , Some ( true ) ) ;
35
38
}
36
39
37
40
#[ test]
38
41
fn test_file_auto_not_found ( ) {
39
- let mut c = Config :: default ( ) ;
40
- let res = c. merge ( File :: with_name ( "tests/NoSettings" ) ) ;
42
+ let mut c = Config :: builder ( ) ;
43
+ c. add_source ( File :: with_name ( "tests/NoSettings" ) ) ;
44
+ let res = c. build ( ) ;
41
45
42
46
assert ! ( res. is_err( ) ) ;
43
47
assert_eq ! (
@@ -48,8 +52,10 @@ fn test_file_auto_not_found() {
48
52
49
53
#[ test]
50
54
fn test_file_ext ( ) {
51
- let mut c = Config :: default ( ) ;
52
- c. merge ( File :: with_name ( "tests/Settings.json" ) ) . unwrap ( ) ;
55
+ let mut builder = Config :: builder ( ) ;
56
+ builder. add_source ( File :: with_name ( "tests/Settings.json" ) ) ;
57
+
58
+ let c = builder. build ( ) . unwrap ( ) ;
53
59
54
60
assert_eq ! ( c. get( "debug" ) . ok( ) , Some ( true ) ) ;
55
61
assert_eq ! ( c. get( "production" ) . ok( ) , Some ( false ) ) ;
0 commit comments