Skip to content

Commit

Permalink
Merge pull request #18 from myhealthily/test-coverage
Browse files Browse the repository at this point in the history
Back to 100% coverage
  • Loading branch information
jhheider authored May 29, 2021
2 parents 334f30a + 0120f09 commit fe14c75
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Tests/CO₂Tests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,24 @@ extension CO₂Tests {
try isOK($0)
})
}

func testRedirect() throws {
app.routes.get("foo", use: sublimate(in: .transaction) { rq -> Response in
rq.redirect(to: URL(string: "/bar")!)
})

try app.testable(method: .inMemory).test(.GET, "foo", afterResponse: { rsp -> Void in
XCTAssertEqual(rsp.status, .seeOther)
XCTAssertEqual(rsp.headers[.location], ["/bar"])
return
})
}
}

extension CO₂Tests {
// for code coverage
func testProperties() throws {
app.routes.get("foo", use: sublimate(in: .transaction) { rq in
app.routes.grouped(app.sessions.middleware).get("foo", use: sublimate(in: .transaction) { rq in
_ = rq.auth
_ = rq.headers
_ = rq.content
Expand All @@ -202,6 +214,10 @@ extension CO₂Tests {
_ = rq.query
_ = rq.logger
_ = rq.application
_ = rq.body
_ = rq.environment
_ = rq.session
_ = ConcreteCO₂DB(db: rq.db).eventLoop
})

try app.testable(method: .inMemory).test(.GET, "foo", afterResponse: isOK)
Expand Down
8 changes: 8 additions & 0 deletions Tests/FluentTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ final class FluentTests: CO₂TestCase {
}.wait()
}

func testAllTransaction() throws {
try db.sublimate(in: .transaction) { db in
XCTAssertEqual(
try Star.query(on: db).all(),
self.input.map(\.0))
}.wait()
}

func testFilter() throws {
try db.sublimate { db in
XCTAssertEqual(
Expand Down

0 comments on commit fe14c75

Please sign in to comment.