@@ -111,10 +111,11 @@ struct POSCatalogSyncCoordinatorTests {
111111 let thirtyMinutesAgo = Date ( ) . addingTimeInterval ( - 30 * 60 )
112112 try createSiteInDatabase ( siteID: sampleSiteID, lastFullSyncDate: thirtyMinutesAgo)
113113
114- // When - max age is 1 hour
115- let _ = try await sut. performFullSyncIfApplicable ( for: sampleSiteID, maxAge: sampleMaxAge)
114+ // When - max age is 1 hour / Then
115+ await #expect( throws: POSCatalogSyncError . shouldNotSync) {
116+ try await sut. performFullSyncIfApplicable ( for: sampleSiteID, maxAge: sampleMaxAge)
117+ }
116118
117- // Then
118119 #expect( mockSyncService. startFullSyncCallCount == 0 )
119120 }
120121
@@ -128,11 +129,12 @@ struct POSCatalogSyncCoordinatorTests {
128129 try createSiteInDatabase ( siteID: siteA, lastFullSyncDate: oneHourAgo)
129130 try createSiteInDatabase ( siteID: siteB, lastFullSyncDate: nil )
130131
131- // When
132- let _ = try await sut. performFullSyncIfApplicable ( for: siteA, maxAge: 2 * sampleMaxAge)
132+ // When / Then
133+ await #expect( throws: POSCatalogSyncError . shouldNotSync) {
134+ let _ = try await sut. performFullSyncIfApplicable ( for: siteA, maxAge: 2 * sampleMaxAge)
135+ }
133136 let _ = try await sut. performFullSyncIfApplicable ( for: siteB, maxAge: 2 * sampleMaxAge)
134137
135- // Then
136138 #expect( mockSyncService. startFullSyncCallCount == 1 )
137139 #expect( mockSyncService. lastSyncSiteID == siteB)
138140 }
@@ -168,9 +170,11 @@ struct POSCatalogSyncCoordinatorTests {
168170 try createSiteInDatabase ( siteID: sampleSiteID, lastFullSyncDate: recentSyncDate)
169171
170172 // When - max age is 1 hour
171- let _ = try await sut. performFullSyncIfApplicable ( for: sampleSiteID, maxAge: sampleMaxAge)
172-
173173 // Then - should not sync because site exists and time hasn't passed
174+ await #expect( throws: POSCatalogSyncError . shouldNotSync) {
175+ let _ = try await sut. performFullSyncIfApplicable ( for: sampleSiteID, maxAge: sampleMaxAge)
176+ }
177+
174178 #expect( mockSyncService. startFullSyncCallCount == 0 )
175179 }
176180
@@ -639,10 +643,11 @@ extension POSCatalogSyncCoordinatorTests {
639643 )
640644 try createSiteInDatabase ( siteID: sampleSiteID, lastFullSyncDate: nil )
641645
642- // When
643- try await coordinator. performSmartSync ( for: sampleSiteID)
646+ // When / Then - sync should be skipped
647+ await #expect( throws: POSCatalogSyncError . shouldNotSync) {
648+ try await coordinator. performSmartSync ( for: sampleSiteID)
649+ }
644650
645- // Then - sync should be skipped
646651 #expect( mockSyncService. startFullSyncCallCount == 0 )
647652 #expect( mockIncrementalSyncService. startIncrementalSyncCallCount == 0 )
648653 }
0 commit comments