From 0f0577da104843d373198f5f7b5356008a576a50 Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 13 May 2025 14:34:01 +0200 Subject: [PATCH 1/2] update test --- PadelClubDataTests/DeletionTests.swift | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/PadelClubDataTests/DeletionTests.swift b/PadelClubDataTests/DeletionTests.swift index 3b39b66..8ebc671 100644 --- a/PadelClubDataTests/DeletionTests.swift +++ b/PadelClubDataTests/DeletionTests.swift @@ -50,6 +50,32 @@ struct DeletionTests { let _: CustomUser = try await storeCenter.service().login(username: username, password: password) } + @Test func testDeleteDependencies() async throws { + + guard let user = StoreCenter.main.userId else { + throw TestError.notAuthenticated + } + + let teamRegCol: SyncedCollection = await StoreCenter.main.mainStore.asyncLoadingSynchronizedCollection() + let playerRegCol: SyncedCollection = await StoreCenter.main.mainStore.asyncLoadingSynchronizedCollection() + + let tr1 = TeamRegistration(tournament: "1") + let pr11 = PlayerRegistration(teamRegistration: tr1.id, firstName: "a1", lastName: "b1") + let pr12 = PlayerRegistration(teamRegistration: tr1.id, firstName: "a1", lastName: "b2") + let tr2 = TeamRegistration(tournament: "1") + let pr21 = PlayerRegistration(teamRegistration: tr2.id, firstName: "a2", lastName: "b1") + let pr22 = PlayerRegistration(teamRegistration: tr2.id, firstName: "a2", lastName: "b2") + + try await teamRegCol.addOrUpdateAsync(contentOfs: [tr1, tr2]) + try await playerRegCol.addOrUpdateAsync(contentOfs: [pr11, pr12, pr21, pr22]) + + try await teamRegCol.deleteAsync(instance: tr1) + + #expect(teamRegCol.count == 1) + #expect(playerRegCol.count == 2) + + } + /// This test creates a hierarchy of objects and deletes to see if everything has been properly deleted @Test func testDeleteEventWithDependencies() async throws { From 54800d385912bf233e54d3df09b92ff9dae0097f Mon Sep 17 00:00:00 2001 From: Laurent Date: Tue, 13 May 2025 14:36:54 +0200 Subject: [PATCH 2/2] update test --- PadelClubDataTests/DeletionTests.swift | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/PadelClubDataTests/DeletionTests.swift b/PadelClubDataTests/DeletionTests.swift index 8ebc671..9641dfa 100644 --- a/PadelClubDataTests/DeletionTests.swift +++ b/PadelClubDataTests/DeletionTests.swift @@ -51,11 +51,7 @@ struct DeletionTests { } @Test func testDeleteDependencies() async throws { - - guard let user = StoreCenter.main.userId else { - throw TestError.notAuthenticated - } - + let teamRegCol: SyncedCollection = await StoreCenter.main.mainStore.asyncLoadingSynchronizedCollection() let playerRegCol: SyncedCollection = await StoreCenter.main.mainStore.asyncLoadingSynchronizedCollection()