Skip to content

Commit

Permalink
Fix workers still running in the background during unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Joannis committed Oct 25, 2023
1 parent 297eaff commit e026b9a
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Tests/MongoQueueTests/MongoQueueTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ final class MongoQueueTests: XCTestCase {
try await Task.sleep(nanoseconds: 10_000_000_000)

XCTAssertEqual(Self.ranTasks, 4)
queue.shutdown()
}

@available(macOS 13.0, *)
Expand All @@ -47,6 +48,7 @@ final class MongoQueueTests: XCTestCase {
XCTAssertLessThanOrEqual(Date().timeIntervalSince(start), 2)

XCTAssertEqual(Self.ranTasks, 6)
queue.shutdown()
}

@available(macOS 13.0, *)
Expand All @@ -72,6 +74,7 @@ final class MongoQueueTests: XCTestCase {
XCTAssertLessThanOrEqual(Date().timeIntervalSince(start), 7)

XCTAssertEqual(Self.ranTasks, 6)
queue.shutdown()
}

func testNoDuplicateQueuedTasksOfSameUniqueKey() async throws {
Expand Down Expand Up @@ -100,6 +103,7 @@ final class MongoQueueTests: XCTestCase {

try await queue.runUntilEmpty()
try await queue.queueTask(UniqueTask())
queue.shutdown()
}

func testDuplicatedOfDifferentTasksCanExist() async throws {
Expand Down Expand Up @@ -147,6 +151,7 @@ final class MongoQueueTests: XCTestCase {
try await queue.runUntilEmpty()
try await queue.queueTask(UniqueTask())
try await queue.queueTask(UniqueTask2())
queue.shutdown()
}

func test_recurringTask() async throws {
Expand All @@ -163,6 +168,7 @@ final class MongoQueueTests: XCTestCase {
try await Task.sleep(nanoseconds: 5_000_000_000)

XCTAssertEqual(Self.ranTasks, 5)
queue.shutdown()
}
}

Expand Down

0 comments on commit e026b9a

Please sign in to comment.