Skip to content

Commit f262441

Browse files
committed
Fix memory leak in tests
1 parent 57733b5 commit f262441

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Tests/SteamPressTests/BlogTests/DisabledBlogTagTests.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@ class DisabledBlogTagTests: XCTestCase {
55
func testDisabledBlogTagsPath() throws {
66
var testWorld = try TestWorld.create(enableTagPages: false)
77
_ = try testWorld.createTag("Engineering")
8-
let tagResponse = try testWorld.getResponse(to: "/tags/Engineering")
9-
let allTagsResponse = try testWorld.getResponse(to: "/tags")
8+
var tagResponse: Response? = try testWorld.getResponse(to: "/tags/Engineering")
9+
var allTagsResponse: Response? = try testWorld.getResponse(to: "/tags")
1010

11-
XCTAssertEqual(.notFound, tagResponse.http.status)
12-
XCTAssertEqual(.notFound, allTagsResponse.http.status)
11+
XCTAssertEqual(.notFound, tagResponse?.http.status)
12+
XCTAssertEqual(.notFound, allTagsResponse?.http.status)
13+
14+
tagResponse = nil
15+
allTagsResponse = nil
16+
17+
XCTAssertNoThrow(try testWorld.tryAsHardAsWeCanToShutdownApplication())
1318
}
1419
}

Tests/SteamPressTests/Helpers/TestWorld.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ struct TestWorld {
3131

3232
// To work around Vapor 3 dodgy lifecycle mess
3333
mutating func tryAsHardAsWeCanToShutdownApplication() throws {
34+
if let threadPool = try context.app?.make(BlockingIOThreadPool.self) {
35+
try threadPool.syncShutdownGracefully()
36+
}
37+
3438
struct ApplicationDidNotGoAway: Error {
3539
var description: String
3640
}

0 commit comments

Comments
 (0)