// // LeStorageTests.swift // LeStorageTests // // Created by Laurent Morvillier on 18/09/2024. // import Testing import LeStorage class IntObject: ModelObject, Storable { static func resourceName() -> String { "int" } static func tokenExemptedMethods() -> [LeStorage.HTTPMethod] { [] } static var relationshipNames: [String] = [] var id: Int var name: String init(id: Int, name: String) { self.id = id self.name = name } } class StringObject: ModelObject, Storable { static func resourceName() -> String { "string" } static func tokenExemptedMethods() -> [LeStorage.HTTPMethod] { [] } static var relationshipNames: [String] = [] var id: String var name: String init(id: String, name: String) { self.id = id self.name = name } } struct IdentifiableTests { @Test func testIntIds() async throws { let intObjects: StoredCollection = Store.main.registerCollection() let int = IntObject(id: 12, name: "test") intObjects.addOrUpdate(instance: int) if let search = intObjects.findById(12) { #expect(search.id == 12) } else { Issue.record("object is missing") } } @Test func testStringIds() async throws { let stringObjects: StoredCollection = Store.main.registerCollection() let string = StringObject(id: "coco", name: "name") stringObjects.addOrUpdate(instance: string) if let search = stringObjects.findById("coco") { #expect(search.id == "coco") } else { Issue.record("object is missing") } } }