11@testable import App
2- import XCTVapor
2+ import VaporTesting
33import Testing
44import Fluent
55
@@ -24,7 +24,7 @@ struct AppTests {
2424 @Test ( " Test Hello World Route " )
2525 func helloWorld( ) async throws {
2626 try await withApp { app in
27- try await app. test ( . GET, " hello " , afterResponse: { res async in
27+ try await app. testing ( ) . test ( . GET, " hello " , afterResponse: { res async in
2828 #expect( res. status == . ok)
2929 #expect( res. body. string == " Hello, world! " )
3030 } )
@@ -37,7 +37,7 @@ struct AppTests {
3737 let sampleTodos = [ Todo ( title: " sample1 " ) , Todo ( title: " sample2 " ) ]
3838 try await sampleTodos. create ( on: app. db)
3939
40- try await app. test ( . GET, " todos " , afterResponse: { res async throws in
40+ try await app. testing ( ) . test ( . GET, " todos " , afterResponse: { res async throws in
4141 #expect( res. status == . ok)
4242 #expect( try res. content. decode ( [ TodoDTO ] . self) == sampleTodos. map { $0. toDTO ( ) } )
4343 } )
@@ -49,13 +49,12 @@ struct AppTests {
4949 let newDTO = TodoDTO ( id: nil , title: " test " )
5050
5151 try await withApp { app in
52- try await app. test ( . POST, " todos " , beforeRequest: { req in
52+ try await app. testing ( ) . test ( . POST, " todos " , beforeRequest: { req in
5353 try req. content. encode ( newDTO)
5454 } , afterResponse: { res async throws in
5555 #expect( res. status == . ok)
5656 let models = try await Todo . query ( on: app. db) . all ( )
5757 #expect( models. map ( { $0. toDTO ( ) . title } ) == [ newDTO. title] )
58- XCTAssertEqual ( models. map { $0. toDTO ( ) } , [ newDTO] )
5958 } )
6059 }
6160 }
@@ -67,7 +66,7 @@ struct AppTests {
6766 try await withApp { app in
6867 try await testTodos. create ( on: app. db)
6968
70- try await app. test ( . DELETE, " todos/ \( testTodos [ 0 ] . requireID ( ) ) " , afterResponse: { res async throws in
69+ try await app. testing ( ) . test ( . DELETE, " todos/ \( testTodos [ 0 ] . requireID ( ) ) " , afterResponse: { res async throws in
7170 #expect( res. status == . noContent)
7271 let model = try await Todo . find ( testTodos [ 0 ] . id, on: app. db)
7372 #expect( model == nil )
0 commit comments