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 // Cleanup
let eventCol: SyncedCollection<Event> = await StoreCenter.main.mainStore.asyncLoadingSynchronizedCollection() let eventCol: SyncedCollection<Event> = await StoreCenter.main.mainStore.asyncLoadingSynchronizedCollection()
eventCol.reset() // let events: [Event] = try await StoreCenter.main.service().get()
let events: [Event] = try await StoreCenter.main.service().get() try await eventCol.deleteAsync(contentOfs: Array(eventCol))
try await eventCol.deleteAsync(contentOfs: Array(events))
#expect(eventCol.count == 0) #expect(eventCol.count == 0)
let tournamentCol: SyncedCollection<Tournament> = await StoreCenter.main.mainStore.asyncLoadingSynchronizedCollection() let tournamentCol: SyncedCollection<Tournament> = await StoreCenter.main.mainStore.asyncLoadingSynchronizedCollection()
tournamentCol.reset() // let tournaments: [Tournament] = try await StoreCenter.main.service().get()
let tournaments: [Tournament] = try await StoreCenter.main.service().get() try await tournamentCol.deleteAsync(contentOfs: Array(tournamentCol))
try await tournamentCol.deleteAsync(contentOfs: Array(tournaments))
#expect(tournamentCol.count == 0) #expect(tournamentCol.count == 0)
// Create // 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) try await eventCol.addOrUpdateAsync(instance: event)
let tournament: Tournament = Tournament.fake() let tournament: Tournament = Tournament.fake()
@ -66,10 +63,10 @@ struct PadelClubDataTests {
try await tournamentCol.addOrUpdateAsync(instance: tournament) try await tournamentCol.addOrUpdateAsync(instance: tournament)
// Test server content // Test server content
try await eventCol.loadDataFromServerIfAllowed(clear: true) try await eventCol.loadOnceAsync()
#expect(eventCol.count == 1) #expect(eventCol.count == 1)
try await tournamentCol.loadDataFromServerIfAllowed(clear: true) try await tournamentCol.loadOnceAsync()
#expect(tournamentCol.count == 1) #expect(tournamentCol.count == 1)
} }

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

Loading…
Cancel
Save