Skip to content

Commit

Permalink
Updated unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
colemancda committed Aug 19, 2023
1 parent 9a22ec1 commit 8f2cb7e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Tests/CoreModelTests/CoreDataTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ final class CoreDataTests: XCTestCase {
var campgroundData = try campground.encode(log: { print("Encoder:", $0) })
try await store.insert(campgroundData)
let rentalUnitData = try rentalUnit.encode(log: { print("Encoder:", $0) })
try await store.insert(rentalUnit)
XCTAssertEqual(rentalUnitData.relationships[PropertyKey(Campground.RentalUnit.CodingKeys.campground)], .toOne(ObjectID(campground.id)))
try await store.insert(rentalUnitData)
campgroundData = try await store.fetch(Campground.entityName, for: ObjectID(campground.id))!
campground = try .init(from: campgroundData, log: { print("Decoder:", $0) })
XCTAssertEqual(campground.units, [rentalUnit.id])
//let fetchedRentalUnit = try await store.fetch(Campground.RentalUnit.self, for: rentalUnit.id)
//XCTAssertEqual(fetchedRentalUnit, rentalUnit)
XCTAssertEqual(campgroundData.relationships[PropertyKey(Campground.CodingKeys.units)], .toMany([ObjectID(rentalUnit.id)]))
let fetchedRentalUnit = try await store.fetch(Campground.RentalUnit.self, for: rentalUnit.id)
XCTAssertEqual(fetchedRentalUnit, rentalUnit)
}
}

Expand Down

0 comments on commit 8f2cb7e

Please sign in to comment.