@@ -247,28 +247,23 @@ async fn unlock(infra: i32, conn: DBConnection) -> ApiResult<Custom<JsonValue>>
247
247
248
248
#[ cfg( test) ]
249
249
mod tests {
250
- use crate :: create_server;
251
250
use crate :: infra:: Infra ;
252
251
use crate :: schema:: operation:: { Operation , RailjsonObject } ;
253
252
use crate :: schema:: SwitchType ;
253
+ use crate :: views:: tests:: create_test_client;
254
254
use rocket:: http:: { ContentType , Status } ;
255
- use rocket:: local:: blocking:: Client ;
256
255
use serde:: Deserialize ;
257
256
258
257
#[ test]
259
258
fn infra_list ( ) {
260
- let rocket = create_server ( & Default :: default ( ) , & Default :: default ( ) , Default :: default ( ) ) ;
261
-
262
- let client = Client :: tracked ( rocket) . expect ( "valid rocket instance" ) ;
259
+ let client = create_test_client ( ) ;
263
260
let response = client. get ( "/infra" ) . dispatch ( ) ;
264
261
assert_eq ! ( response. status( ) , Status :: Ok ) ;
265
262
}
266
263
267
264
#[ test]
268
265
fn infra_create_delete ( ) {
269
- let rocket = create_server ( & Default :: default ( ) , & Default :: default ( ) , Default :: default ( ) ) ;
270
-
271
- let client = Client :: tracked ( rocket) . expect ( "valid rocket instance" ) ;
266
+ let client = create_test_client ( ) ;
272
267
let create_infra_response = client
273
268
. post ( "/infra" )
274
269
. header ( ContentType :: JSON )
@@ -289,9 +284,7 @@ mod tests {
289
284
290
285
#[ test]
291
286
fn infra_get ( ) {
292
- let rocket = create_server ( & Default :: default ( ) , & Default :: default ( ) , Default :: default ( ) ) ;
293
-
294
- let client = Client :: tracked ( rocket) . expect ( "valid rocket instance" ) ;
287
+ let client = create_test_client ( ) ;
295
288
let create_infra_response = client
296
289
. post ( "/infra" )
297
290
. header ( ContentType :: JSON )
@@ -317,8 +310,7 @@ mod tests {
317
310
318
311
#[ test]
319
312
fn infra_rename ( ) {
320
- let rocket = create_server ( & Default :: default ( ) , & Default :: default ( ) , Default :: default ( ) ) ;
321
- let client = Client :: tracked ( rocket) . expect ( "valid rocket instance" ) ;
313
+ let client = create_test_client ( ) ;
322
314
let create_infra = client
323
315
. post ( "/infra" )
324
316
. header ( ContentType :: JSON )
@@ -342,10 +334,7 @@ mod tests {
342
334
343
335
#[ test]
344
336
fn infra_refresh ( ) {
345
- let rocket = create_server ( & Default :: default ( ) , & Default :: default ( ) , Default :: default ( ) ) ;
346
-
347
- let client = Client :: tracked ( rocket) . expect ( "valid rocket instance" ) ;
348
-
337
+ let client = create_test_client ( ) ;
349
338
let create_infra_response = client
350
339
. post ( "/infra" )
351
340
. header ( ContentType :: JSON )
@@ -378,10 +367,7 @@ mod tests {
378
367
379
368
#[ test]
380
369
fn infra_refresh_force ( ) {
381
- let rocket = create_server ( & Default :: default ( ) , & Default :: default ( ) , Default :: default ( ) ) ;
382
-
383
- let client = Client :: tracked ( rocket) . expect ( "valid rocket instance" ) ;
384
-
370
+ let client = create_test_client ( ) ;
385
371
let create_infra = client
386
372
. post ( "/infra" )
387
373
. header ( ContentType :: JSON )
@@ -413,10 +399,7 @@ mod tests {
413
399
414
400
#[ test]
415
401
fn infra_get_switch_types ( ) {
416
- let rocket = create_server ( & Default :: default ( ) , & Default :: default ( ) , Default :: default ( ) ) ;
417
-
418
- let client = Client :: tracked ( rocket) . expect ( "valid rocket instance" ) ;
419
-
402
+ let client = create_test_client ( ) ;
420
403
let create_infra = client
421
404
. post ( "/infra" )
422
405
. header ( ContentType :: JSON )
@@ -459,10 +442,7 @@ mod tests {
459
442
460
443
#[ test]
461
444
fn infra_lock ( ) {
462
- let rocket = create_server ( & Default :: default ( ) , & Default :: default ( ) , Default :: default ( ) ) ;
463
-
464
- let client = Client :: tracked ( rocket) . expect ( "valid rocket instance" ) ;
465
-
445
+ let client = create_test_client ( ) ;
466
446
let create_infra = client
467
447
. post ( "/infra" )
468
448
. header ( ContentType :: JSON )
0 commit comments