Failing test for compareRecordsByPrimaryKey option of FetchedRecordsController when record has no primary key

This commit is contained in:
Gwendal Roué committed 2016-10-17 20:16:31 +02:00
1 parent c687c5df24
commit 2acfbcdce6
1 file changed
+45
@@ -640,4 +640,49 @@ class PrimaryKeyHiddenRowIDTests : GRDBTestCase {
}
}
}
// MARK: - FetchedRecordsController
func testFetchedRecordsController() {
assertNoError {
let dbQueue = try makeDatabaseQueue()
let person = Person(name: "Arthur")
try dbQueue.inDatabase { db in
try person.insert(db)
}
let expectation = self.expectation(description: "expectation")
let controller = FetchedRecordsController<Person>(dbQueue, request: Person.all(), compareRecordsByPrimaryKey: true)
#if os(iOS)
var update = false
controller.trackChanges(
tableViewEvent: { (_, _, event) in
switch event {
case .update:
update = true
default:
break
}
},
recordsDidChange: { _ in
expectation.fulfill()
})
#else
controller.trackChanges { _ in
expectation.fulfill()
}
#endif
controller.performFetch()
try dbQueue.inDatabase { db in
person.name = "Barbara"
try person.update(db)
}
waitForExpectations(timeout: 1, handler: nil)
#if os(iOS)
XCTAssertTrue(update)
#endif
}
}
}