Skip to content

Commit e0a9711

Browse files
committed
update unit tests
1 parent f75304a commit e0a9711

File tree

2 files changed

+10
-21
lines changed

2 files changed

+10
-21
lines changed

Tests/OpenAPILambdaTests/Router/RouterGraphTest.swift

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414
//===----------------------------------------------------------------------===//
1515
import HTTPTypes
1616
import OpenAPIRuntime
17+
import Testing
1718

1819
@testable import OpenAPILambda
1920

20-
// only run unit tests on Swift 6.x
21-
#if swift(>=6.0)
22-
import Testing
23-
2421
struct RouterGraphTests {
2522
@Test("Path with no parameters")
2623
func testPathNoParams() async throws {
@@ -231,7 +228,7 @@ struct RouterGraphTests {
231228
// let method = HTTPRequest.Method(strMethod)!
232229
// let graph = prepareGraph(for: method)
233230
//
234-
// let root: Node? = graph.root()
231+
// let root: node? = graph.root()
235232
// XCTAssertNotNil(root)
236233
//
237234
// // when
@@ -323,9 +320,8 @@ struct RouterGraphTests {
323320

324321
//when
325322
#expect(throws: Never.self) { try graph.find(method: method, path: pathToTest) }
326-
let (handler, metadata) = try graph.find(method: method, path: pathToTest)
323+
let (_, metadata) = try graph.find(method: method, path: pathToTest)
327324
#expect(metadata.count == 0)
328-
#expect(handler != nil)
329325
}
330326

331327
@Test(
@@ -338,19 +334,18 @@ struct RouterGraphTests {
338334
)
339335
func testFindHandler2(
340336
pathToTest: String
341-
) throws {
337+
) async throws {
342338
// given
343339
let strMethod = "GET"
344340
let method = HTTPRequest.Method(strMethod)!
345341
let graph = prepareGraphForFind(for: method)
346342

347343
//when
348344
#expect(throws: Never.self) {
349-
let (handler, metadata) = try graph.find(method: method, path: pathToTest)
345+
let (_, metadata) = try graph.find(method: method, path: pathToTest)
350346

351347
// then (we can not test if the query string param have been decoded, that's the job of the openapi runtime.)
352348
#expect(metadata.count == 1)
353-
#expect(handler != nil)
354349
}
355350

356351
}
@@ -365,9 +360,8 @@ struct RouterGraphTests {
365360

366361
//when
367362
#expect(throws: Never.self) { try graph.find(method: method, path: pathToTest) }
368-
let (handler, metadata) = try graph.find(method: method, path: pathToTest)
363+
let (_, metadata) = try graph.find(method: method, path: pathToTest)
369364
#expect(metadata.count == 1)
370-
#expect(handler != nil)
371365
}
372366

373367
@Test("Find handler error 1")
@@ -440,4 +434,3 @@ struct RouterGraphTests {
440434
}
441435

442436
}
443-
#endif

Tests/OpenAPILambdaTests/Router/RouterNodeTest.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,10 @@
1414
//===----------------------------------------------------------------------===//
1515
import HTTPTypes
1616
import OpenAPIRuntime
17+
import Testing
1718

1819
@testable import OpenAPILambda
1920

20-
// only run unit tests on Swift 6.x
21-
#if swift(>=6.0)
22-
import Testing
23-
2421
struct RouterNodeTests {
2522
@Test("First node is root")
2623
func testFirstNodeIsRoot() throws {
@@ -114,7 +111,7 @@ struct RouterNodeTests {
114111
}
115112

116113
@Test("Cannot add node to handler")
117-
func testCanNotAddNodeToHandler() {
114+
func testCanNotAddNodeToHandler() async {
118115
// given
119116
let bodyString = "bodyString"
120117
let handler: OpenAPIHandler = { a, b, c in (HTTPResponse(status: .ok), HTTPBody(bodyString)) }
@@ -180,7 +177,7 @@ struct RouterNodeTests {
180177
}
181178

182179
@Test("Retrieve param child exists")
183-
func testRetrieveParamChildExist() {
180+
func testRetrieveParamChildExist() async {
184181
// given
185182
let pathElement = "element1"
186183
let root = Node()
@@ -196,7 +193,7 @@ struct RouterNodeTests {
196193
}
197194

198195
@Test("Retrieve param child does not exist")
199-
func testRetrieveParamChildNOTExist() {
196+
func testRetrieveParamChildNOTExist() async {
200197
// given
201198
let pathElement = "element1"
202199
let root = Node()
@@ -212,4 +209,3 @@ struct RouterNodeTests {
212209
}
213210

214211
}
215-
#endif

0 commit comments

Comments
 (0)