@@ -2,6 +2,7 @@ import XCTest
22import Combine
33@testable import OpenFeature
44
5+ // swiftlint:disable type_body_length file_length trailing_closure
56class AsyncCoalescingSerialQueueTests : XCTestCase {
67 override func setUp( ) {
78 super. setUp ( )
@@ -89,7 +90,10 @@ class AsyncCoalescingSerialQueueTests: XCTestCase {
8990
9091 let finalState = OpenFeatureAPI . shared. getState ( )
9192 XCTAssertNotNil ( finalState. provider, " Provider should not be nil after concurrent operations " )
92- XCTAssertNotNil ( finalState. evaluationContext, " Evaluation context should not be nil after concurrent operations " )
93+ XCTAssertNotNil (
94+ finalState. evaluationContext,
95+ " Evaluation context should not be nil after concurrent operations "
96+ )
9397 XCTAssertTrue ( [ . ready] . contains ( finalState. providerStatus) , " Provider status should be in a valid final state " )
9498
9599 if let context = finalState. evaluationContext {
@@ -161,13 +165,17 @@ class AsyncCoalescingSerialQueueTests: XCTestCase {
161165
162166 let contextMap = context? . asObjectMap ( ) ?? [ : ]
163167 if contextMap. keys. contains ( " iteration " ) {
164- XCTAssertTrue ( contextMap. keys. contains ( " timestamp " ) , " Context with iteration should also have timestamp " )
168+ XCTAssertTrue (
169+ contextMap. keys. contains ( " timestamp " ) ,
170+ " Context with iteration should also have timestamp "
171+ )
165172 }
166173 } else {
167174 XCTFail ( " Provider or Evaluation Context unexpectedly nil " )
168175 }
169176 }
170177
178+ // swiftlint:disable:next function_body_length
171179 func testAsyncCoalescingSerialQueueCoalescence( ) async throws {
172180 // Track which operations actually executed
173181 actor ExecutionTracker {
@@ -186,7 +194,7 @@ class AsyncCoalescingSerialQueueTests: XCTestCase {
186194
187195 // Create a provider with a slow onContextSet to ensure operations overlap
188196 let provider = MockProvider (
189- onContextSet: { oldContext , newContext in
197+ onContextSet: { _ , newContext in
190198 // Add delay to simulate slow provider operation
191199 // This ensures that when tasks 2 and 3 are queued, task 1 is still running
192200 let targetingKey = newContext. getTargetingKey ( )
@@ -241,7 +249,10 @@ class AsyncCoalescingSerialQueueTests: XCTestCase {
241249 XCTAssertLessThanOrEqual (
242250 executedOperations. count,
243251 2 ,
244- " Should execute at most 2 operations due to coalescence (first + latest), but executed: \( executedOperations) "
252+ """
253+ Should execute at most 2 operations due to coalescence (first + latest), \
254+ but executed: \( executedOperations)
255+ """
245256 )
246257
247258 // Verify user2 was NOT executed (it should be coalesced/skipped)
@@ -273,7 +284,7 @@ class AsyncCoalescingSerialQueueTests: XCTestCase {
273284
274285 let tracker = ExecutionTracker ( )
275286 let provider = MockProvider (
276- onContextSet: { oldContext , newContext in
287+ onContextSet: { _ , newContext in
277288 await tracker. recordExecution ( newContext. getTargetingKey ( ) )
278289 }
279290 )
@@ -304,7 +315,7 @@ class AsyncCoalescingSerialQueueTests: XCTestCase {
304315
305316 let tracker = ExecutionTracker ( )
306317 let provider = MockProvider (
307- onContextSet: { oldContext , newContext in
318+ onContextSet: { _ , newContext in
308319 await tracker. recordExecution ( newContext. getTargetingKey ( ) )
309320 try await Task . sleep ( nanoseconds: 10_000_000 ) // 10ms
310321 }
@@ -344,7 +355,7 @@ class AsyncCoalescingSerialQueueTests: XCTestCase {
344355
345356 let tracker = ExecutionTracker ( )
346357 let provider = MockProvider (
347- onContextSet: { oldContext , newContext in
358+ onContextSet: { _ , newContext in
348359 await tracker. recordExecution ( newContext. getTargetingKey ( ) )
349360 try await Task . sleep ( nanoseconds: 100_000_000 ) // 100ms - long enough for many to queue
350361 }
@@ -395,7 +406,7 @@ class AsyncCoalescingSerialQueueTests: XCTestCase {
395406
396407 let tracker = ExecutionTracker ( )
397408 let provider = MockProvider (
398- onContextSet: { oldContext , newContext in
409+ onContextSet: { _ , newContext in
399410 await tracker. recordExecution ( newContext. getTargetingKey ( ) )
400411 }
401412 )
@@ -464,7 +475,7 @@ class AsyncCoalescingSerialQueueTests: XCTestCase {
464475
465476 let tracker = ExecutionTracker ( )
466477 let provider = MockProvider (
467- onContextSet: { oldContext , newContext in
478+ onContextSet: { _ , newContext in
468479 let targetingKey = newContext. getTargetingKey ( )
469480 await tracker. recordExecution ( targetingKey)
470481
@@ -543,7 +554,7 @@ class AsyncCoalescingSerialQueueTests: XCTestCase {
543554
544555 let completionTracker = CompletionTracker ( )
545556 let provider = MockProvider (
546- onContextSet: { oldContext , newContext in
557+ onContextSet: { _ , _ in
547558 try await Task . sleep ( nanoseconds: 50_000_000 ) // 50ms
548559 }
549560 )
@@ -594,7 +605,7 @@ class AsyncCoalescingSerialQueueTests: XCTestCase {
594605
595606 let tracker = ExecutionTracker ( )
596607 let provider = MockProvider (
597- onContextSet: { oldContext , newContext in
608+ onContextSet: { _ , newContext in
598609 await tracker. recordExecution ( newContext. getTargetingKey ( ) )
599610 try await Task . sleep ( nanoseconds: 20_000_000 ) // 20ms
600611 }
@@ -609,7 +620,10 @@ class AsyncCoalescingSerialQueueTests: XCTestCase {
609620 group. addTask {
610621 let ctx = ImmutableContext (
611622 targetingKey: " wave \( wave) -user \( i) " ,
612- structure: ImmutableStructure ( attributes: [ " wave " : . integer( Int64 ( wave) ) , " id " : . integer( Int64 ( i) ) ] )
623+ structure: ImmutableStructure ( attributes: [
624+ " wave " : . integer( Int64 ( wave) ) ,
625+ " id " : . integer( Int64 ( i) ) ,
626+ ] )
613627 )
614628 await OpenFeatureAPI . shared. setEvaluationContextAndWait ( evaluationContext: ctx)
615629 }
@@ -639,3 +653,4 @@ class AsyncCoalescingSerialQueueTests: XCTestCase {
639653 )
640654 }
641655}
656+ // swiftlint:enable type_body_length file_length trailing_closure
0 commit comments