From 297eaff739a060a2ac1a8b8b0bfe69465a980910 Mon Sep 17 00:00:00 2001 From: Joannis Orlandos Date: Thu, 26 Oct 2023 00:16:22 +0200 Subject: [PATCH] Fix the unit tests --- Tests/MongoQueueTests/MongoQueueTests.swift | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Tests/MongoQueueTests/MongoQueueTests.swift b/Tests/MongoQueueTests/MongoQueueTests.swift index 66061c0..aac057e 100644 --- a/Tests/MongoQueueTests/MongoQueueTests.swift +++ b/Tests/MongoQueueTests/MongoQueueTests.swift @@ -26,6 +26,7 @@ final class MongoQueueTests: XCTestCase { @available(macOS 13.0, *) func testMaxParallelJobs() async throws { + Self.ranTasks = 0 let db = try await MongoDatabase.connect(to: settings) try await db.drop() let queue = MongoQueue(collection: db["tasks"]) @@ -43,13 +44,14 @@ final class MongoQueueTests: XCTestCase { try await queue.runUntilEmpty() - XCTAssertLessThanOrEqual(-start.timeIntervalSinceNow, 2) + XCTAssertLessThanOrEqual(Date().timeIntervalSince(start), 2) XCTAssertEqual(Self.ranTasks, 6) } @available(macOS 13.0, *) func testMaxParallelJobsLow() async throws { + Self.ranTasks = 0 let db = try await MongoDatabase.connect(to: settings) try await db.drop() let queue = MongoQueue(collection: db["tasks"]) @@ -67,7 +69,7 @@ final class MongoQueueTests: XCTestCase { try await queue.runUntilEmpty() - XCTAssertGreaterThanOrEqual(-start.timeIntervalSinceNow, 6) + XCTAssertLessThanOrEqual(Date().timeIntervalSince(start), 7) XCTAssertEqual(Self.ranTasks, 6) }