Fix test issue

sync3
Laurent 6 months ago
parent 77a035b643
commit 5fa72a27a3
  1. 1
      PadelClubDataTests/PadelClubDataTests.swift
  2. 12
      PadelClubDataTests/SynchronizationTests.swift

@ -11,6 +11,7 @@ import Testing
enum TestError: Error {
case notAuthenticated
case sameDeviceId
}
struct PadelClubDataTests {

@ -22,6 +22,8 @@ struct SynchronizationTests {
self.secondStoreCenter.configureURLs(secureScheme: false, domain: "127.0.0.1:8000", webSockets: false)
self.secondStoreCenter.tokenKeychain = MockKeychainStore(fileName: "storage-2/token.json")
self.secondStoreCenter.deviceKeychain = MockKeychainStore(fileName: "storage-2/device.json")
try self.secondStoreCenter.deviceKeychain.add(value: UUID().uuidString)
self.secondStoreCenter.classProject = "PadelClubData"
let token2 = try? self.secondStoreCenter.rawTokenShouldNotBeUsed()
@ -32,6 +34,7 @@ struct SynchronizationTests {
StoreCenter.main.configureURLs(secureScheme: false, domain: "127.0.0.1:8000", webSockets: false)
StoreCenter.main.tokenKeychain = MockKeychainStore(fileName: "storage/token.json")
StoreCenter.main.deviceKeychain = MockKeychainStore(fileName: "storage/device.json")
try StoreCenter.main.deviceKeychain.add(value: UUID().uuidString)
StoreCenter.main.classProject = "PadelClubData"
let token = try? StoreCenter.main.rawTokenShouldNotBeUsed()
@ -44,6 +47,11 @@ struct SynchronizationTests {
let _: CustomUser = try await storeCenter.service().login(username: self.username, password: self.password)
}
@Test("device id tests")
func testDeviceIds() async throws {
#expect(StoreCenter.main.deviceId() != self.secondStoreCenter.deviceId())
}
@Test func testAuthentication() {
#expect(StoreCenter.main.isAuthenticated)
#expect(self.secondStoreCenter.isAuthenticated)
@ -75,8 +83,8 @@ struct SynchronizationTests {
try await eventCollection1.loadDataFromServerIfAllowed(clear: true)
#expect(eventCollection1.count == 1)
try await eventCollection2.loadDataFromServerIfAllowed(clear: true)
#expect(eventCollection2.count == 1)
// try await eventCollection2.loadDataFromServerIfAllowed(clear: true)
// #expect(eventCollection2.count == 1)
try await self.secondStoreCenter.testSynchronizeOnceAsync()
#expect(eventCollection2.count == 1)

Loading…
Cancel
Save