From cf4d26370afce42cbc80b9352311229096902785 Mon Sep 17 00:00:00 2001 From: Laurent Date: Thu, 3 Apr 2025 17:58:44 +0200 Subject: [PATCH] fix tests --- LeStorage/ApiCallCollection.swift | 2 +- LeStorageTests/ApiCallTests.swift | 5 ++++- LeStorageTests/CollectionsTests.swift | 7 ++++++- LeStorageTests/IdentifiableTests.swift | 1 + LeStorageTests/StoredCollectionTests.swift | 1 + 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/LeStorage/ApiCallCollection.swift b/LeStorage/ApiCallCollection.swift index b52d8f2..5ea5fa1 100644 --- a/LeStorage/ApiCallCollection.swift +++ b/LeStorage/ApiCallCollection.swift @@ -318,7 +318,7 @@ actor ApiCallCollection: SomeCallCollection { } /// Sends a GET request with an optional [storeId] - func sendGetRequest(storeId: String?, clear: Bool) async throws { + func sendGetRequest(storeId: String?, clear: Bool = true) async throws { var parameters: [String : String]? = nil if let storeId { parameters = [Services.storeIdURLParameter : storeId] diff --git a/LeStorageTests/ApiCallTests.swift b/LeStorageTests/ApiCallTests.swift index 87e46ec..e68b142 100644 --- a/LeStorageTests/ApiCallTests.swift +++ b/LeStorageTests/ApiCallTests.swift @@ -9,13 +9,16 @@ import Testing @testable import LeStorage class Thing: SyncedModelObject, SyncedStorable, URLParameterConvertible { + override required init() { + super.init() + } static func resourceName() -> String { return "thing" } static func tokenExemptedMethods() -> [LeStorage.HTTPMethod] { return [] } static func filterByStoreIdentifier() -> Bool { return false } var id: String = Store.randomId() - var name: String + var name: String = "" init(name: String) { self.name = name diff --git a/LeStorageTests/CollectionsTests.swift b/LeStorageTests/CollectionsTests.swift index cf8cf8b..77ca937 100644 --- a/LeStorageTests/CollectionsTests.swift +++ b/LeStorageTests/CollectionsTests.swift @@ -24,8 +24,12 @@ class Boat: ModelObject, SyncedStorable { var id: String = Store.randomId() var lastUpdate: Date = Date() - var shared: Bool? + var shared: Bool? = false + override required init() { + super.init() + } + static func tokenExemptedMethods() -> [LeStorage.HTTPMethod] { return [] } static func resourceName() -> String { return "boat" } @@ -61,6 +65,7 @@ struct CollectionsTests { // Wait a bit before checking again try await Task.sleep(for: .milliseconds(100)) } + collection.reset() } @Test func differentiationTest() async throws { diff --git a/LeStorageTests/IdentifiableTests.swift b/LeStorageTests/IdentifiableTests.swift index 76d5661..493b156 100644 --- a/LeStorageTests/IdentifiableTests.swift +++ b/LeStorageTests/IdentifiableTests.swift @@ -74,6 +74,7 @@ struct IdentifiableTests { // Wait a bit before checking again try await Task.sleep(for: .milliseconds(100)) } + collection.reset() } @Test func testIntIds() async throws { diff --git a/LeStorageTests/StoredCollectionTests.swift b/LeStorageTests/StoredCollectionTests.swift index 7c11ea4..a1772d8 100644 --- a/LeStorageTests/StoredCollectionTests.swift +++ b/LeStorageTests/StoredCollectionTests.swift @@ -38,6 +38,7 @@ struct StoredCollectionTests { // Wait a bit before checking again try await Task.sleep(for: .milliseconds(100)) } + collection.reset() } @Test func testInitialization() async throws {