Skip to content

Commit 87b06f9

Browse files
committed
Use expect(throws) for shorter tests.
1 parent c8ab269 commit 87b06f9

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

Modules/Tests/YosemiteTests/Tools/POS/POSCatalogSyncCoordinatorTests.swift

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,8 @@ struct POSCatalogSyncCoordinatorTests {
195195
try await Task.sleep(nanoseconds: 10_000_000) // 10ms
196196

197197
// When - try to start second sync while first is blocked
198-
do {
198+
await #expect(throws: POSCatalogSyncError.syncAlreadyInProgress(siteID: sampleSiteID)) {
199199
_ = try await sut.performFullSync(for: sampleSiteID)
200-
#expect(Bool(false), "Should have thrown syncAlreadyInProgress error")
201-
} catch let error as POSCatalogSyncError {
202-
// Then
203-
#expect(error == POSCatalogSyncError.syncAlreadyInProgress(siteID: sampleSiteID))
204200
}
205201

206202
let currentState = await sut.loadLastFullSyncState(for: sampleSiteID)
@@ -370,12 +366,8 @@ struct POSCatalogSyncCoordinatorTests {
370366
try await Task.sleep(nanoseconds: 10_000_000) // 10ms
371367

372368
// When - try to start second incremental sync while first is blocked
373-
do {
374-
_ = try await sut.performIncrementalSyncIfApplicable(for: sampleSiteID, maxAge: sampleMaxAge)
375-
#expect(Bool(false), "Should have thrown syncAlreadyInProgress error")
376-
} catch let error as POSCatalogSyncError {
377-
// Then
378-
#expect(error == POSCatalogSyncError.syncAlreadyInProgress(siteID: sampleSiteID))
369+
await #expect(throws: POSCatalogSyncError.syncAlreadyInProgress(siteID: sampleSiteID)) {
370+
try await sut.performIncrementalSyncIfApplicable(for: sampleSiteID, maxAge: sampleMaxAge)
379371
}
380372

381373
// Cleanup

0 commit comments

Comments
 (0)