@@ -324,12 +324,13 @@ struct POSCatalogSyncCoordinatorTests {
324324 #expect( mockSyncService. startFullSyncCallCount == 0 )
325325 }
326326
327- @Test func performIncrementalSyncIfApplicable_skips_sync_when_no_full_sync_performed( ) async throws {
327+ @Test ( arguments: [ . zero, 60 * 60 ] )
328+ func performIncrementalSyncIfApplicable_skips_sync_when_no_full_sync_performed( maxAge: TimeInterval ) async throws {
328329 // Given - site exists but has no full sync date
329330 try createSiteInDatabase ( siteID: sampleSiteID, lastFullSyncDate: nil )
330331
331332 // When
332- try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: . zero )
333+ try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: maxAge )
333334
334335 // Then
335336 #expect( mockIncrementalSyncService. startIncrementalSyncCallCount == 0 )
@@ -356,9 +357,9 @@ struct POSCatalogSyncCoordinatorTests {
356357 #expect( mockIncrementalSyncService. startIncrementalSyncCallCount == 0 )
357358 }
358359
359- @Test func performIncrementalSyncIfApplicable_performs_sync_when_incremental_sync_is_stale( ) async throws {
360+ @Test ( arguments: [ . zero, 2 ] )
361+ func performIncrementalSyncIfApplicable_performs_sync_when_incremental_sync_is_stale( maxAge: TimeInterval ) async throws {
360362 // Given
361- let maxAge : TimeInterval = 2
362363 let incrementalSyncDate = Date ( ) . addingTimeInterval ( - ( maxAge + 0.2 ) ) // Just above max age
363364 let fullSyncDate = Date ( ) . addingTimeInterval ( - 3600 )
364365 try createSiteInDatabase ( siteID: sampleSiteID, lastFullSyncDate: fullSyncDate, lastIncrementalSyncDate: incrementalSyncDate)
@@ -378,13 +379,14 @@ struct POSCatalogSyncCoordinatorTests {
378379 #expect( mockIncrementalSyncService. lastSyncSiteID == sampleSiteID)
379380 }
380381
381- @Test func performIncrementalSyncIfApplicable_performs_sync_when_no_incremental_sync_date( ) async throws {
382+ @Test ( arguments: [ . zero, 60 * 60 ] )
383+ func performIncrementalSyncIfApplicable_performs_sync_when_no_incremental_sync_date( maxAge: TimeInterval ) async throws {
382384 // Given
383385 let fullSyncDate = Date ( ) . addingTimeInterval ( - 3600 )
384386 try createSiteInDatabase ( siteID: sampleSiteID, lastFullSyncDate: fullSyncDate, lastIncrementalSyncDate: nil )
385387
386388 // When
387- try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: sampleMaxAge )
389+ try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: maxAge )
388390
389391 // Then
390392 #expect( mockIncrementalSyncService. startIncrementalSyncCallCount == 1 )
@@ -473,7 +475,8 @@ struct POSCatalogSyncCoordinatorTests {
473475 }
474476 }
475477
476- @Test func performIncrementalSyncIfApplicable_incremental_tracking_cleaned_up_on_error( ) async throws {
478+ @Test ( arguments: [ . zero, 60 * 60 ] )
479+ func performIncrementalSyncIfApplicable_incremental_tracking_cleaned_up_on_error( maxAge: TimeInterval ) async throws {
477480 // Given
478481 let fullSyncDate = Date ( ) . addingTimeInterval ( - 3600 )
479482 try createSiteInDatabase ( siteID: sampleSiteID, lastFullSyncDate: fullSyncDate)
@@ -483,7 +486,7 @@ struct POSCatalogSyncCoordinatorTests {
483486
484487 // When - incremental sync fails
485488 do {
486- _ = try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: sampleMaxAge )
489+ _ = try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: maxAge )
487490 #expect( Bool ( false ) , " Should have thrown error " )
488491 } catch {
489492 // Expected error
@@ -498,60 +501,64 @@ struct POSCatalogSyncCoordinatorTests {
498501
499502 // MARK: - Incremental Sync Catalog Size Tests
500503
501- @Test func performIncrementalSyncIfApplicable_skips_sync_when_catalog_size_exceeds_limit( ) async throws {
504+ @Test ( arguments: [ . zero, 60 * 60 ] )
505+ func performIncrementalSyncIfApplicable_skips_sync_when_catalog_size_exceeds_limit( maxAge: TimeInterval ) async throws {
502506 // Given - catalog size is above the 1000 item limit
503507 mockCatalogSizeChecker. checkCatalogSizeResult = . success( POSCatalogSize ( productCount: 700 , variationCount: 400 ) ) // 1100 total
504508 let fullSyncDate = Date ( ) . addingTimeInterval ( - 3600 )
505509 try createSiteInDatabase ( siteID: sampleSiteID, lastFullSyncDate: fullSyncDate)
506510
507511 // When
508- try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: sampleMaxAge )
512+ try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: maxAge )
509513
510514 // Then
511515 #expect( mockIncrementalSyncService. startIncrementalSyncCallCount == 0 )
512516 #expect( mockCatalogSizeChecker. checkCatalogSizeCallCount == 1 )
513517 #expect( mockCatalogSizeChecker. lastCheckedSiteID == sampleSiteID)
514518 }
515519
516- @Test func performIncrementalSyncIfApplicable_performs_sync_when_catalog_size_is_at_limit( ) async throws {
520+ @Test ( arguments: [ . zero, 60 * 60 ] )
521+ func performIncrementalSyncIfApplicable_performs_sync_when_catalog_size_is_at_limit( maxAge: TimeInterval ) async throws {
517522 // Given - catalog size is exactly at the 1000 item limit
518523 mockCatalogSizeChecker. checkCatalogSizeResult = . success( POSCatalogSize ( productCount: 500 , variationCount: 500 ) ) // 1000 total
519524 let fullSyncDate = Date ( ) . addingTimeInterval ( - 3600 )
520525 try createSiteInDatabase ( siteID: sampleSiteID, lastFullSyncDate: fullSyncDate)
521526
522527 // When
523- try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: sampleMaxAge )
528+ try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: maxAge )
524529
525530 // Then
526531 #expect( mockIncrementalSyncService. startIncrementalSyncCallCount == 1 )
527532 #expect( mockCatalogSizeChecker. checkCatalogSizeCallCount == 1 )
528533 #expect( mockCatalogSizeChecker. lastCheckedSiteID == sampleSiteID)
529534 }
530535
531- @Test func performIncrementalSyncIfApplicable_performs_sync_when_catalog_size_is_under_limit( ) async throws {
536+ @Test ( arguments: [ . zero, 60 * 60 ] )
537+ func performIncrementalSyncIfApplicable_performs_sync_when_catalog_size_is_under_limit( maxAge: TimeInterval ) async throws {
532538 // Given - catalog size is below the 1000 item limit
533539 mockCatalogSizeChecker. checkCatalogSizeResult = . success( POSCatalogSize ( productCount: 200 , variationCount: 150 ) ) // 350 total
534540 let fullSyncDate = Date ( ) . addingTimeInterval ( - 3600 )
535541 try createSiteInDatabase ( siteID: sampleSiteID, lastFullSyncDate: fullSyncDate)
536542
537543 // When
538- try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: sampleMaxAge )
544+ try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: maxAge )
539545
540546 // Then
541547 #expect( mockIncrementalSyncService. startIncrementalSyncCallCount == 1 )
542548 #expect( mockCatalogSizeChecker. checkCatalogSizeCallCount == 1 )
543549 #expect( mockCatalogSizeChecker. lastCheckedSiteID == sampleSiteID)
544550 }
545551
546- @Test func performIncrementalSyncIfApplicable_skips_sync_when_catalog_size_check_fails( ) async throws {
552+ @Test ( arguments: [ . zero, 60 * 60 ] )
553+ func performIncrementalSyncIfApplicable_skips_sync_when_catalog_size_check_fails( maxAge: TimeInterval ) async throws {
547554 // Given - catalog size check throws an error
548555 let sizeCheckError = NSError ( domain: " size_check " , code: 500 , userInfo: [ NSLocalizedDescriptionKey: " Network error " ] )
549556 mockCatalogSizeChecker. checkCatalogSizeResult = . failure( sizeCheckError)
550557 let fullSyncDate = Date ( ) . addingTimeInterval ( - 3600 )
551558 try createSiteInDatabase ( siteID: sampleSiteID, lastFullSyncDate: fullSyncDate)
552559
553560 // When
554- try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: sampleMaxAge )
561+ try await sut. performIncrementalSyncIfApplicable ( for: sampleSiteID, maxAge: maxAge )
555562
556563 // Then - should skip sync when size check fails
557564 #expect( mockIncrementalSyncService. startIncrementalSyncCallCount == 0 )
0 commit comments