Skip to content

Commit

Permalink
Fix test failures with Swift version <5.8 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
juyan authored Jan 16, 2024
2 parents b15e162 + 8dd2c31 commit 9f2e14a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Tests/SwiftFileStoreTests/FileObjectStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ final class FileObjectStoreTests: XCTestCase {
XCTAssertEqual(values, [nil, object, object2])
expectation2.fulfill()
}
await fulfillment(of: [expectation], timeout: 1)
await fulfillmentCompat(expectations: [expectation], timeout: 1)
try await store.write(key: "test", namespace: "test", object: object)
try await store.write(key: "test", namespace: "test", object: object2)
await fulfillment(of: [expectation2], timeout: 1)
await fulfillmentCompat(expectations: [expectation2], timeout: 1)
}
}
4 changes: 2 additions & 2 deletions Tests/SwiftFileStoreTests/MemoryObjectStoreTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ final class MemoryObjectStoreTests: XCTestCase {
XCTAssertEqual(values, [nil, object, object2])
expectation2.fulfill()
}
await fulfillment(of: [expectation], timeout: 1)
await fulfillmentCompat(expectations: [expectation], timeout: 1)
try await store.write(key: "test", namespace: "test", object: object)
try await store.write(key: "test", namespace: "test", object: object2)
await fulfillment(of: [expectation2], timeout: 1)
await fulfillmentCompat(expectations: [expectation2], timeout: 1)
}
}
21 changes: 21 additions & 0 deletions Tests/SwiftFileStoreTests/XCTestCase+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// File.swift
//
//
// Created by Jun Yan on 1/15/24.
//

import Foundation
import XCTest

extension XCTestCase {


func fulfillmentCompat(expectations: [XCTestExpectation], timeout: TimeInterval) async {
#if swift(>=5.8)
await fulfillment(of: expectations, timeout: timeout)
#else
wait(for: expectations, timeout: timeout)
#endif
}
}

0 comments on commit 9f2e14a

Please sign in to comment.