@@ -12,29 +12,21 @@ lab.experiment('config', function () {
12
12
var configPath = path . join ( __dirname , 'database.json' ) ;
13
13
var _config = config . load ( configPath , 'dev' ) ;
14
14
15
- lab . test (
16
- 'should export all environment settings' ,
17
-
18
- function ( done ) {
19
- Code . expect ( _config . dev ) . to . exists ( ) ;
20
- Code . expect ( _config . test ) . to . exists ( ) ;
21
- Code . expect ( _config . prod ) . to . exists ( ) ;
22
- done ( ) ;
23
- }
24
- ) ;
15
+ lab . test ( 'should export all environment settings' , ( ) => {
16
+ Code . expect ( _config . dev ) . to . exists ( ) ;
17
+ Code . expect ( _config . test ) . to . exists ( ) ;
18
+ Code . expect ( _config . prod ) . to . exists ( ) ;
19
+ } ) ;
25
20
26
21
lab . test (
27
22
'should export a getCurrent function with all current ' +
28
- 'environment settings' ,
29
-
30
- function ( done ) {
23
+ 'environment settings' , ( ) => {
31
24
var current ;
32
25
Code . expect ( _config . getCurrent ) . to . exists ( ) ;
33
26
current = _config . getCurrent ( ) ;
34
27
Code . expect ( current . env ) . to . equal ( 'dev' ) ;
35
28
Code . expect ( current . settings . driver ) . to . equal ( 'sqlite3' ) ;
36
29
Code . expect ( current . settings . filename ) . to . equal ( ':memory:' ) ;
37
- done ( ) ;
38
30
}
39
31
) ;
40
32
} ) ;
@@ -45,12 +37,11 @@ lab.experiment('config', function () {
45
37
function ( ) {
46
38
var configPath = path . join ( __dirname , 'database_with_syntax_error.json' ) ;
47
39
48
- lab . test ( 'should throw a syntax error' , function ( done ) {
40
+ lab . test ( 'should throw a syntax error' , async ( ) => {
49
41
Code . expect (
50
42
config . load . bind ( this , configPath , 'dev' ) ,
51
43
'Expected broken file to produce syntax error'
52
44
) . to . throw ( SyntaxError ) ;
53
- done ( ) ;
54
45
} ) ;
55
46
}
56
47
) ;
@@ -63,14 +54,11 @@ lab.experiment('config', function () {
63
54
var _config = config . load ( configPath ) ;
64
55
65
56
lab . test (
66
- 'should load a value from the default env' ,
67
-
68
- function ( done ) {
57
+ 'should load a value from the default env' , ( ) => {
69
58
var current = _config . getCurrent ( ) ;
70
59
Code . expect ( current . env ) . to . equal ( 'local' ) ;
71
60
Code . expect ( current . settings . driver ) . to . equal ( 'sqlite3' ) ;
72
61
Code . expect ( current . settings . filename ) . to . equal ( ':memory:' ) ;
73
- done ( ) ;
74
62
}
75
63
) ;
76
64
}
@@ -88,13 +76,10 @@ lab.experiment('config', function () {
88
76
var _config = config . load ( configPath ) ;
89
77
90
78
lab . test (
91
- 'should load a value from the env set in NODE_ENV' ,
92
-
93
- function ( done ) {
79
+ 'should load a value from the env set in NODE_ENV' , ( ) => {
94
80
var current = _config . getCurrent ( ) ;
95
81
Code . expect ( current . settings . driver ) . to . equal ( 'sqlite3' ) ;
96
82
Code . expect ( current . settings . filename ) . to . equal ( ':memory:' ) ;
97
- done ( ) ;
98
83
}
99
84
) ;
100
85
}
@@ -109,11 +94,8 @@ lab.experiment('config', function () {
109
94
var _config = config . load ( configPath , 'prod' ) ;
110
95
111
96
lab . test (
112
- 'should load a value from the environments' ,
113
-
114
- function ( done ) {
97
+ 'should load a value from the environments' , ( ) => {
115
98
Code . expect ( _config . prod . username ) . to . equal ( 'username_from_env' ) ;
116
- done ( ) ;
117
99
}
118
100
) ;
119
101
}
@@ -128,16 +110,13 @@ lab.experiment('config', function () {
128
110
var _config = config . load ( configPath , 'prod' ) ;
129
111
130
112
lab . test (
131
- 'should load a value from the environments' ,
132
-
133
- function ( done ) {
113
+ 'should load a value from the environments' , ( ) => {
134
114
var current = _config . getCurrent ( ) ;
135
115
Code . expect ( current . settings . driver ) . to . equal ( 'postgres' ) ;
136
116
Code . expect ( current . settings . user ) . to . equal ( 'uname' ) ;
137
117
Code . expect ( current . settings . password ) . to . equal ( 'pw' ) ;
138
118
Code . expect ( current . settings . host ) . to . equal ( 'server.com' ) ;
139
119
Code . expect ( current . settings . database ) . to . equal ( 'dbname' ) ;
140
- done ( ) ;
141
120
}
142
121
) ;
143
122
}
@@ -148,19 +127,14 @@ lab.experiment('config', function () {
148
127
var _config = config . loadUrl ( databaseUrl , 'dev' ) ;
149
128
150
129
lab . test (
151
- 'should export the settings as the current environment' ,
152
-
153
- function ( done ) {
130
+ 'should export the settings as the current environment' , ( ) => {
154
131
Code . expect ( _config . dev ) . to . exists ( ) ;
155
- done ( ) ;
156
132
}
157
133
) ;
158
134
159
135
lab . test (
160
136
'should export a getCurrent function with all current ' +
161
- 'environment settings' ,
162
-
163
- function ( done ) {
137
+ 'environment settings' , ( ) => {
164
138
var current ;
165
139
Code . expect ( _config . getCurrent ) . to . exists ( ) ;
166
140
current = _config . getCurrent ( ) ;
@@ -170,7 +144,6 @@ lab.experiment('config', function () {
170
144
Code . expect ( current . settings . password ) . to . equal ( 'pw' ) ;
171
145
Code . expect ( current . settings . host ) . to . equal ( 'server.com' ) ;
172
146
Code . expect ( current . settings . database ) . to . equal ( 'dbname' ) ;
173
- done ( ) ;
174
147
}
175
148
) ;
176
149
} ) ;
@@ -180,14 +153,13 @@ lab.experiment('config', function () {
180
153
config . load = _configLoad ;
181
154
config . loadUrl = _configLoadUrl ;
182
155
183
- lab . test ( 'should something' , function ( done ) {
156
+ lab . test ( 'should something' , ( ) => {
184
157
Code . expect ( config . load . bind ( this , configPath , 'dev' ) ) . to . not . throw ( ) ;
185
- done ( ) ;
186
158
} ) ;
187
159
} ) ;
188
160
189
161
lab . experiment ( 'loading a url from url property' , function ( ) {
190
- lab . test ( 'should export a valid config' , function ( done ) {
162
+ lab . test ( 'should export a valid config' , ( ) => {
191
163
var databaseUrl = {
192
164
dev : {
193
165
url :
'postgres://uname:[email protected] /dbname'
@@ -204,13 +176,9 @@ lab.experiment('config', function () {
204
176
Code . expect ( current . settings . password ) . to . equal ( 'pw' ) ;
205
177
Code . expect ( current . settings . host ) . to . equal ( 'server.com' ) ;
206
178
Code . expect ( current . settings . database ) . to . equal ( 'dbname' ) ;
207
-
208
- done ( ) ;
209
179
} ) ;
210
180
211
- lab . test ( 'should export the value if specified in suboject' , function (
212
- done
213
- ) {
181
+ lab . test ( 'should export the value if specified in suboject' , ( ) => {
214
182
var databaseUrl = {
215
183
dev : {
216
184
url : {
@@ -224,8 +192,6 @@ lab.experiment('config', function () {
224
192
var current = cfg . getCurrent ( ) ;
225
193
Code . expect ( current . env ) . to . equal ( 'dev' ) ;
226
194
Code . expect ( current . settings . url ) . to . equal ( 'http://example.com' ) ;
227
-
228
- done ( ) ;
229
195
} ) ;
230
196
} ) ;
231
197
@@ -241,16 +207,12 @@ lab.experiment('config', function () {
241
207
242
208
var cfg = config . loadObject ( databaseUrl , 'dev' ) ;
243
209
244
- lab . test ( 'should export the settings as the current environment' , function (
245
- done
246
- ) {
210
+ lab . test ( 'should export the settings as the current environment' , ( ) => {
247
211
Code . expect ( cfg . dev ) . to . exists ( ) ;
248
- done ( ) ;
249
212
} ) ;
250
213
251
214
lab . test (
252
- 'should export a getCurrent function with all current environment settings' ,
253
- function ( done ) {
215
+ 'should export a getCurrent function with all current environment settings' , ( ) => {
254
216
Code . expect ( cfg . getCurrent ) . to . exists ( ) ;
255
217
var current = cfg . getCurrent ( ) ;
256
218
Code . expect ( current . env ) . to . equal ( 'dev' ) ;
@@ -262,8 +224,6 @@ lab.experiment('config', function () {
262
224
Code . expect ( current . settings . host ) . to . equal ( 'server.com' ) ;
263
225
Code . expect ( current . settings . database ) . to . equal ( 'dbname' ) ;
264
226
Code . expect ( current . settings . ssl ) . to . equal ( true ) ;
265
-
266
- done ( ) ;
267
227
}
268
228
) ;
269
229
} ) ;
@@ -273,7 +233,7 @@ lab.experiment('config', function () {
273
233
function ( ) {
274
234
lab . test (
275
235
'should export a getCurrent function with all current environment settings' ,
276
- function ( done , cleanup ) {
236
+ function ( flags ) {
277
237
process . env . DATABASE_URL = 'postgres://uname:[email protected] /dbname' ;
278
238
var databaseUrl = {
279
239
dev : {
@@ -285,10 +245,9 @@ lab.experiment('config', function () {
285
245
} ;
286
246
var cfg = config . loadObject ( databaseUrl , 'dev' ) ;
287
247
288
- cleanup ( function ( next ) {
248
+ flags . onCleanup = ( ) => {
289
249
delete process . env . DATABASE_URL ;
290
- next ( ) ;
291
- } ) ;
250
+ } ;
292
251
293
252
Code . expect ( cfg . getCurrent ) . to . exists ( ) ;
294
253
var current = cfg . getCurrent ( ) ;
@@ -301,8 +260,6 @@ lab.experiment('config', function () {
301
260
Code . expect ( current . settings . host ) . to . equal ( 'server.com' ) ;
302
261
Code . expect ( current . settings . database ) . to . equal ( 'dbname' ) ;
303
262
Code . expect ( current . settings . ssl ) . to . equal ( true ) ;
304
-
305
- done ( ) ;
306
263
}
307
264
) ;
308
265
}
@@ -311,7 +268,7 @@ lab.experiment('config', function () {
311
268
lab . experiment (
312
269
'loading from an ENV URL within the object and extending it from the ENV' ,
313
270
function ( ) {
314
- lab . test ( '' , function ( done , cleanup ) {
271
+ lab . test ( '' , function ( flags ) {
315
272
process . env . DATABASE_URL =
316
273
'postgres://uname:[email protected] /dbname?ssl=false&testing=false' ;
317
274
var databaseUrl = {
@@ -332,10 +289,9 @@ lab.experiment('config', function () {
332
289
} ;
333
290
var cfg = config . loadObject ( databaseUrl , 'dev' ) ;
334
291
335
- cleanup ( function ( next ) {
292
+ flags . onCleanup = ( ) => {
336
293
delete process . env . DATABASE_URL ;
337
- next ( ) ;
338
- } ) ;
294
+ } ;
339
295
340
296
Code . expect ( cfg . getCurrent ) . to . exists ( ) ;
341
297
var current = cfg . getCurrent ( ) ;
@@ -352,8 +308,6 @@ lab.experiment('config', function () {
352
308
Code . expect ( current . settings . testing ) . to . equal ( 'false' ) ;
353
309
Code . expect ( current . settings . cache ) . to . equal ( false ) ;
354
310
Code . expect ( current . settings . ssl ) . to . equal ( true ) ;
355
-
356
- done ( ) ;
357
311
} ) ;
358
312
}
359
313
) ;
0 commit comments