From d7e63d0193cdb521e8062be6d5cd7979f3921af3 Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 3 Jun 2025 11:42:20 +0200 Subject: [PATCH] fix tests --- PadelClubDataTests/PadelClubDataTests.swift | 17 +++++++---------- PadelClubDataTests/SyncDataAccessTests.swift | 6 +++--- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/PadelClubDataTests/PadelClubDataTests.swift b/PadelClubDataTests/PadelClubDataTests.swift index 545249d..f25dd10 100644 --- a/PadelClubDataTests/PadelClubDataTests.swift +++ b/PadelClubDataTests/PadelClubDataTests.swift @@ -44,21 +44,18 @@ struct PadelClubDataTests { } // Cleanup - let eventCol: SyncedCollection = await StoreCenter.main.mainStore.asyncLoadingSynchronizedCollection() - eventCol.reset() - let events: [Event] = try await StoreCenter.main.service().get() - try await eventCol.deleteAsync(contentOfs: Array(events)) +// let events: [Event] = try await StoreCenter.main.service().get() + try await eventCol.deleteAsync(contentOfs: Array(eventCol)) #expect(eventCol.count == 0) let tournamentCol: SyncedCollection = await StoreCenter.main.mainStore.asyncLoadingSynchronizedCollection() - tournamentCol.reset() - let tournaments: [Tournament] = try await StoreCenter.main.service().get() - try await tournamentCol.deleteAsync(contentOfs: Array(tournaments)) +// let tournaments: [Tournament] = try await StoreCenter.main.service().get() + try await tournamentCol.deleteAsync(contentOfs: Array(tournamentCol)) #expect(tournamentCol.count == 0) // Create - let event: Event = Event(creator: userId, club: nil, name: "test") + let event: Event = Event(creator: userId, club: nil, name: "test_createTournament") try await eventCol.addOrUpdateAsync(instance: event) let tournament: Tournament = Tournament.fake() @@ -66,10 +63,10 @@ struct PadelClubDataTests { try await tournamentCol.addOrUpdateAsync(instance: tournament) // Test server content - try await eventCol.loadDataFromServerIfAllowed(clear: true) + try await eventCol.loadOnceAsync() #expect(eventCol.count == 1) - try await tournamentCol.loadDataFromServerIfAllowed(clear: true) + try await tournamentCol.loadOnceAsync() #expect(tournamentCol.count == 1) } diff --git a/PadelClubDataTests/SyncDataAccessTests.swift b/PadelClubDataTests/SyncDataAccessTests.swift index cb78567..8d87e83 100644 --- a/PadelClubDataTests/SyncDataAccessTests.swift +++ b/PadelClubDataTests/SyncDataAccessTests.swift @@ -462,9 +462,9 @@ struct SyncDataAccessTests { let tourStoreB = try self.storeCenterB.store(identifier: tournament.id) - let gsColB: SyncedCollection = try tourStoreB.syncedCollection() - let roundColB: SyncedCollection = try tourStoreB.syncedCollection() - let matchesColB: SyncedCollection = try tourStoreB.syncedCollection() + let gsColB: SyncedCollection = await tourStoreB.asyncLoadingSynchronizedCollection() + let roundColB: SyncedCollection = await tourStoreB.asyncLoadingSynchronizedCollection() + let matchesColB: SyncedCollection = await tourStoreB.asyncLoadingSynchronizedCollection() #expect(gsColB.count == 4) #expect(roundColB.count == 15) #expect(matchesColB.count == 56)