1
1
@testable
2
2
import Alchemy
3
3
import AlchemyTest
4
- import NIOEmbedded
5
4
6
5
final class QueueTests : TestCase < TestApp > {
7
6
private lazy var allTests = [
@@ -82,24 +81,18 @@ final class QueueTests: TestCase<TestApp> {
82
81
let exp = expectation ( description: " " )
83
82
ConfirmableJob . didRun = { exp. fulfill ( ) }
84
83
try await ConfirmableJob ( ) . dispatch ( )
85
-
86
- let loop = EmbeddedEventLoop ( )
87
- Q . startWorker ( )
88
- loop. advanceTime ( by: . seconds( 5 ) )
89
-
90
- await fulfillment ( of: [ exp] , timeout: kMinTimeout)
84
+ app. background ( " queue:work " )
85
+ await fulfillment ( of: [ exp] , timeout: 2 )
91
86
}
92
87
93
88
private func _testFailure( file: StaticString = #filePath, line: UInt = #line) async throws {
94
89
let exp = expectation ( description: " " )
95
90
FailureJob . didFinish = { exp. fulfill ( ) }
96
91
try await FailureJob ( ) . dispatch ( )
97
92
98
- let loop = EmbeddedEventLoop ( )
99
- Q . startWorker ( )
100
- loop. advanceTime ( by: . seconds( 5 ) )
101
-
102
- await fulfillment ( of: [ exp] , timeout: kMinTimeout)
93
+ app. background ( " queue:work " )
94
+
95
+ await fulfillment ( of: [ exp] , timeout: 2 )
103
96
AssertNil ( try await Q . dequeue ( from: [ " default " ] ) )
104
97
}
105
98
@@ -108,10 +101,8 @@ final class QueueTests: TestCase<TestApp> {
108
101
RetryJob . didFail = { exp. fulfill ( ) }
109
102
try await RetryJob ( foo: " bar " ) . dispatch ( )
110
103
111
- let loop = EmbeddedEventLoop ( )
112
- Q . startWorker ( untilEmpty: false )
113
- loop. advanceTime ( by: . seconds( 5 ) )
114
- await fulfillment ( of: [ exp] , timeout: kMinTimeout)
104
+ app. background ( " queue:work " )
105
+ await fulfillment ( of: [ exp] , timeout: 1.1 )
115
106
116
107
guard let jobData = try await Q . dequeue ( from: [ " default " ] ) else {
117
108
XCTFail ( " Failed to dequeue a job. " , file: file, line: line)
0 commit comments