Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ func buildRouter() -> Router<AppRequestContext> {
// logging middleware
LogRequestsMiddleware(.info)
}
// Add health endpoint
router.get("/health") { _, _ -> HTTPResponse.Status in
return .ok
// Add default endpoint
router.get("/") { _,_ in
return "Hello!"
}
router.addRoutes(TodoController(repository: TodoMemoryRepository()).endpoints, atPath: "/todos")
return router
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ func buildRouter(_ repository: some TodoRepository) -> Router<AppRequestContext>
// logging middleware
LogRequestsMiddleware(.info)
}
// Add health endpoint
router.get("/health") { _, _ -> HTTPResponse.Status in
return .ok
// Add default endpoint
router.get("/") { _,_ in
return "Hello!"
}
router.addRoutes(TodoController(repository: repository).endpoints, atPath: "/todos")
return router
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ final class AppTests: XCTestCase {
let args = TestArguments()
let app = try await buildApplication(args)
try await app.test(.router) { client in
try await client.execute(uri: "/health", method: .get) { response in
XCTAssertEqual(response.status, .ok)
try await client.execute(uri: "/", method: .get) { response in
XCTAssertEqual(response.body, ByteBuffer(string: "Hello!"))
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Hummingbird.docc/Tutorials/Todos/Todos-3-Testing.tutorial
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
@Step {
Open Package.swift

You see at the bottom there is a test target call `AppTests`. It is dependent on the target `App` and the library `HummingbirdTesting`.
You see at the bottom there is a test target called `AppTests`. It is dependent on the target `App` and the library `HummingbirdTesting`.
@Code(name: "Package.swift", file: todos-testing-01.swift)
}
@Step {
Open Tests/AppTests/AppTests.swift

It contains one test, `testApp()`. This creates a copy of the Application using `buildApplication(_:)` and uses the Hummingbird test framework to verify the GET `/health` endpoint returns a 200 (Ok) response.
It contains one test, `testApp()`. This creates a copy of the Application using `buildApplication(_:)` and uses the Hummingbird test framework to verify the GET `/` endpoint returns a "Hello!" string.
@Code(name: "Tests/AppTests/AppTests.swift", file: todos-testing-02.swift)
}
@Step {
Expand Down