sync3
Laurent 5 months ago
parent 1ca71b977f
commit d7e63d0193
  1. 17
      PadelClubDataTests/PadelClubDataTests.swift
  2. 6
      PadelClubDataTests/SyncDataAccessTests.swift

@ -44,21 +44,18 @@ struct PadelClubDataTests {
}
// Cleanup
let eventCol: SyncedCollection<Event> = 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<Tournament> = 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)
}

@ -462,9 +462,9 @@ struct SyncDataAccessTests {
let tourStoreB = try self.storeCenterB.store(identifier: tournament.id)
let gsColB: SyncedCollection<GroupStage> = try tourStoreB.syncedCollection()
let roundColB: SyncedCollection<Round> = try tourStoreB.syncedCollection()
let matchesColB: SyncedCollection<Match> = try tourStoreB.syncedCollection()
let gsColB: SyncedCollection<GroupStage> = await tourStoreB.asyncLoadingSynchronizedCollection()
let roundColB: SyncedCollection<Round> = await tourStoreB.asyncLoadingSynchronizedCollection()
let matchesColB: SyncedCollection<Match> = await tourStoreB.asyncLoadingSynchronizedCollection()
#expect(gsColB.count == 4)
#expect(roundColB.count == 15)
#expect(matchesColB.count == 56)

Loading…
Cancel
Save