Skip to content

Commit 620f5d9

Browse files
committed
fix bug with test properties creation and lookup not accounting for new parser attribute.
1 parent 1da1a8b commit 620f5d9

File tree

5 files changed

+10
-4
lines changed

5 files changed

+10
-4
lines changed

Sources/App/Controllers/APITestController.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,8 @@ extension APITestController {
223223
.filter(\.$id == testPropertiesId.rawValue)
224224
.with(\.$openAPISource)
225225
.first()
226-
.optionalMap { ($0, $0.$openAPISource.value!) }
227226
.unwrap(or: Abort(.badRequest, reason: "Given API test properties could not be found."))
227+
.map { ($0, $0.$openAPISource.value!) }
228228
}
229229

230230
/// Attempt to find or create default test properties.
@@ -252,6 +252,7 @@ extension APITestController {
252252
.query(on: db)
253253
.filter(\.$openAPISource.$id == sourceId)
254254
.filter(\.$apiHostOverride == nil)
255+
.filter(\.$parser == .stable)
255256
.first(orCreate: DB.APITestProperties(openAPISourceId: sourceId, apiHostOverride: nil, parser: .stable))
256257
.map { ($0, source) }
257258
}
@@ -385,7 +386,7 @@ extension APITestController {
385386
rootPath.map(\.openAPIPathComponent),
386387
use: self.create
387388
)
388-
.tags("Testing")
389+
.tags("Test Creation")
389390
.summary("Run tests")
390391
.description("""
391392
Running tests is an asynchronous operation. This route will return immediately if it was able to queue up a new test run.
@@ -399,15 +400,15 @@ You can monitor the status of your test run with the `GET` `/api_test/{id}` endp
399400
rootPath.map(\.openAPIPathComponent),
400401
use: self.index
401402
)
402-
.tags("Testing")
403+
.tags("Test Status", "Test Results")
403404
.summary("Retrieve all test results")
404405

405406
app.on(
406407
.GET,
407408
rootPath.map(\.openAPIPathComponent) + [":id".description(idDescription)],
408409
use: self.show
409410
)
410-
.tags("Testing")
411+
.tags("Test Status", "Test Results")
411412
.summary("Retrieve a single test result")
412413

413414
// MARK: File Retrieval

Sources/App/Controllers/APITestMessageController.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,5 +79,7 @@ extension APITestMessageController {
7979
rootPath.map(\.openAPIPathComponent) + [":id".description("Id of the API Test Message.")],
8080
use: Self.show
8181
)
82+
.tags("Test Results")
83+
.summary("Retrieve a single test message")
8284
}
8385
}

Sources/App/Controllers/APITestPropertiesController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ extension APITestPropertiesController {
9292
DB.APITestProperties.query(on: req.db)
9393
.filter(\.$openAPISource.$id == properties.$openAPISource.id)
9494
.filter(\.$apiHostOverride == properties.apiHostOverride)
95+
.filter(\.$parser == properties.parser)
9596
.first(orCreate: properties)
9697
}
9798

Sources/App/Controllers/OpenAPISourceController.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extension OpenAPISourceController {
3232
.flatMap(req.response.success.encode)
3333
}
3434

35+
/// Show an `OpenAPISource`.
3536
func show(_ req: TypedRequest<ShowContext>) throws -> EventLoopFuture<Response> {
3637
guard let id = req.parameters.get("id", as: UUID.self) else {
3738
return req.response.badRequest

Sources/App/Models/DB/APITestProperties+DB.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ extension DB {
4949
self.id = UUID()
5050
self.createdAt = Date()
5151
self.$apiHostOverride.wrappedValue = apiModel.apiHostOverride
52+
self.$parser.wrappedValue = apiModel.parser
5253
self.$openAPISource.id = openAPISourceId
5354
}
5455

0 commit comments

Comments
 (0)