Get iOS tests building again.

This commit is contained in:
Emily Toop 2018-08-06 17:00:38 +01:00 committed by Grisha Kruglov
parent db4350aab7
commit d61e070e08

View file

@ -30,7 +30,7 @@ class MentatTests: XCTestCase {
// test that a store can be opened in memory // test that a store can be opened in memory
func testOpenInMemoryStore() { func testOpenInMemoryStore() {
XCTAssertNotNil(Mentat().raw) XCTAssertNotNil(try Mentat.open().raw)
} }
// test that a store can be opened in a specific location // test that a store can be opened in a specific location
@ -38,7 +38,8 @@ class MentatTests: XCTestCase {
let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask) let paths = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)
let documentsURL = paths[0] let documentsURL = paths[0]
let storeURI = documentsURL.appendingPathComponent("test.db", isDirectory: false).absoluteString let storeURI = documentsURL.appendingPathComponent("test.db", isDirectory: false).absoluteString
XCTAssertNotNil(Mentat(storeURI: storeURI).raw)
XCTAssertNotNil(try Mentat.open(storeURI: storeURI).raw)
} }
func readFile(forResource resource: String, withExtension ext: String, subdirectory: String ) throws -> String { func readFile(forResource resource: String, withExtension ext: String, subdirectory: String ) throws -> String {
@ -80,7 +81,7 @@ class MentatTests: XCTestCase {
func openAndInitializeCitiesStore() -> Mentat { func openAndInitializeCitiesStore() -> Mentat {
guard let mentat = self.store else { guard let mentat = self.store else {
let mentat = Mentat() let mentat = try! Mentat.open()
let _ = try! self.transactCitiesSchema(mentat: mentat) let _ = try! self.transactCitiesSchema(mentat: mentat)
let _ = try! self.transactSeattleData(mentat: mentat) let _ = try! self.transactSeattleData(mentat: mentat)
self.store = mentat self.store = mentat
@ -154,7 +155,7 @@ class MentatTests: XCTestCase {
func test1TransactVocabulary() { func test1TransactVocabulary() {
do { do {
let mentat = Mentat() let mentat = try Mentat.open()
let vocab = try readCitiesSchema() let vocab = try readCitiesSchema()
let report = try mentat.transact(transaction: vocab) let report = try mentat.transact(transaction: vocab)
XCTAssertNotNil(report) XCTAssertNotNil(report)
@ -166,7 +167,7 @@ class MentatTests: XCTestCase {
func test2TransactEntities() { func test2TransactEntities() {
do { do {
let mentat = Mentat() let mentat = try Mentat.open()
let vocab = try readCitiesSchema() let vocab = try readCitiesSchema()
let _ = try mentat.transact(transaction: vocab) let _ = try mentat.transact(transaction: vocab)
let data = try readSeattleData() let data = try readSeattleData()
@ -338,7 +339,7 @@ class MentatTests: XCTestCase {
} }
func testBindLong() { func testBindLong() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a") let aEntid = report!.entid(forTempId: "a")
let query = "[:find ?e . :in ?long :where [?e :foo/long ?long]]" let query = "[:find ?e . :in ?long :where [?e :foo/long ?long]]"
@ -358,7 +359,7 @@ class MentatTests: XCTestCase {
} }
func testBindRef() { func testBindRef() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let stringEntid = mentat.entidForAttribute(attribute: ":foo/string") let stringEntid = mentat.entidForAttribute(attribute: ":foo/string")
let bEntid = report!.entid(forTempId: "b") let bEntid = report!.entid(forTempId: "b")
@ -379,7 +380,7 @@ class MentatTests: XCTestCase {
} }
func testBindKwRef() { func testBindKwRef() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let bEntid = report!.entid(forTempId: "b") let bEntid = report!.entid(forTempId: "b")
let query = "[:find ?e . :in ?ref :where [?e :foo/ref ?ref]]" let query = "[:find ?e . :in ?ref :where [?e :foo/ref ?ref]]"
@ -399,7 +400,7 @@ class MentatTests: XCTestCase {
} }
func testBindKw() { func testBindKw() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a") let aEntid = report!.entid(forTempId: "a")
let query = "[:find ?e . :in ?kw :where [?e :foo/keyword ?kw]]" let query = "[:find ?e . :in ?kw :where [?e :foo/keyword ?kw]]"
@ -419,7 +420,7 @@ class MentatTests: XCTestCase {
} }
func testBindDate() { func testBindDate() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a") let aEntid = report!.entid(forTempId: "a")
let query = "[:find [?e ?d] :in ?now :where [?e :foo/instant ?d] [(< ?d ?now)]]" let query = "[:find [?e ?d] :in ?now :where [?e :foo/instant ?d] [(< ?d ?now)]]"
@ -465,7 +466,7 @@ class MentatTests: XCTestCase {
} }
func testBindUuid() { func testBindUuid() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a") let aEntid = report!.entid(forTempId: "a")
let query = "[:find ?e . :in ?uuid :where [?e :foo/uuid ?uuid]]" let query = "[:find ?e . :in ?uuid :where [?e :foo/uuid ?uuid]]"
@ -486,7 +487,7 @@ class MentatTests: XCTestCase {
} }
func testBindBoolean() { func testBindBoolean() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a") let aEntid = report!.entid(forTempId: "a")
let query = "[:find ?e . :in ?bool :where [?e :foo/boolean ?bool]]" let query = "[:find ?e . :in ?bool :where [?e :foo/boolean ?bool]]"
@ -506,7 +507,7 @@ class MentatTests: XCTestCase {
} }
func testBindDouble() { func testBindDouble() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a") let aEntid = report!.entid(forTempId: "a")
let query = "[:find ?e . :in ?double :where [?e :foo/double ?double]]" let query = "[:find ?e . :in ?double :where [?e :foo/double ?double]]"
@ -526,7 +527,7 @@ class MentatTests: XCTestCase {
} }
func testTypedValueAsLong() { func testTypedValueAsLong() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")! let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/long ?v]]" let query = "[:find ?v . :in ?e :where [?e :foo/long ?v]]"
@ -547,7 +548,7 @@ class MentatTests: XCTestCase {
} }
func testTypedValueAsRef() { func testTypedValueAsRef() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")! let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?e . :where [?e :foo/long 25]]" let query = "[:find ?e . :where [?e :foo/long 25]]"
@ -567,7 +568,7 @@ class MentatTests: XCTestCase {
} }
func testTypedValueAsKw() { func testTypedValueAsKw() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")! let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/keyword ?v]]" let query = "[:find ?v . :in ?e :where [?e :foo/keyword ?v]]"
@ -588,7 +589,7 @@ class MentatTests: XCTestCase {
} }
func testTypedValueAsBoolean() { func testTypedValueAsBoolean() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")! let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/boolean ?v]]" let query = "[:find ?v . :in ?e :where [?e :foo/boolean ?v]]"
@ -609,7 +610,7 @@ class MentatTests: XCTestCase {
} }
func testTypedValueAsDouble() { func testTypedValueAsDouble() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")! let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/double ?v]]" let query = "[:find ?v . :in ?e :where [?e :foo/double ?v]]"
@ -630,7 +631,7 @@ class MentatTests: XCTestCase {
} }
func testTypedValueAsDate() { func testTypedValueAsDate() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")! let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/instant ?v]]" let query = "[:find ?v . :in ?e :where [?e :foo/instant ?v]]"
@ -656,7 +657,7 @@ class MentatTests: XCTestCase {
} }
func testTypedValueAsString() { func testTypedValueAsString() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")! let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/string ?v]]" let query = "[:find ?v . :in ?e :where [?e :foo/string ?v]]"
@ -677,7 +678,7 @@ class MentatTests: XCTestCase {
} }
func testTypedValueAsUuid() { func testTypedValueAsUuid() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")! let aEntid = report!.entid(forTempId: "a")!
let query = "[:find ?v . :in ?e :where [?e :foo/uuid ?v]]" let query = "[:find ?v . :in ?e :where [?e :foo/uuid ?v]]"
@ -699,7 +700,7 @@ class MentatTests: XCTestCase {
} }
func testValueForAttributeOfEntity() { func testValueForAttributeOfEntity() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = report!.entid(forTempId: "a")! let aEntid = report!.entid(forTempId: "a")!
var value: TypedValue? = nil; var value: TypedValue? = nil;
@ -709,14 +710,14 @@ class MentatTests: XCTestCase {
} }
func testEntidForAttribute() { func testEntidForAttribute() {
let mentat = Mentat() let mentat = try! Mentat.open()
let _ = self.populateWithTypesSchema(mentat: mentat) let _ = self.populateWithTypesSchema(mentat: mentat)
let entid = mentat.entidForAttribute(attribute: ":foo/long") let entid = mentat.entidForAttribute(attribute: ":foo/long")
assert(entid == 65540) assert(entid == 65540)
} }
func testMultipleQueries() { func testMultipleQueries() {
let mentat = Mentat() let mentat = try! Mentat.open()
let _ = self.populateWithTypesSchema(mentat: mentat) let _ = self.populateWithTypesSchema(mentat: mentat)
let q1 = mentat.query(query: "[:find ?x :where [?x _ _]]") let q1 = mentat.query(query: "[:find ?x :where [?x _ _]]")
@ -741,7 +742,7 @@ class MentatTests: XCTestCase {
} }
func testNestedQueries() { func testNestedQueries() {
let mentat = Mentat() let mentat = try! Mentat.open()
let _ = self.populateWithTypesSchema(mentat: mentat) let _ = self.populateWithTypesSchema(mentat: mentat)
let q1 = mentat.query(query: "[:find ?x :where [?x _ _]]") let q1 = mentat.query(query: "[:find ?x :where [?x _ _]]")
let q2 = mentat.query(query: "[:find ?x :where [_ _ ?x]]") let q2 = mentat.query(query: "[:find ?x :where [_ _ ?x]]")
@ -763,13 +764,13 @@ class MentatTests: XCTestCase {
} }
func test3InProgressTransact() { func test3InProgressTransact() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
XCTAssertNotNil(report) XCTAssertNotNil(report)
} }
func testInProgressRollback() { func testInProgressRollback() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (_, report) = self.populateWithTypesSchema(mentat: mentat) let (_, report) = self.populateWithTypesSchema(mentat: mentat)
XCTAssertNotNil(report) XCTAssertNotNil(report)
let aEntid = report!.entid(forTempId: "a")! let aEntid = report!.entid(forTempId: "a")!
@ -787,7 +788,7 @@ class MentatTests: XCTestCase {
} }
func testInProgressEntityBuilder() { func testInProgressEntityBuilder() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat) let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
let bEntid = dataReport!.entid(forTempId: "b")! let bEntid = dataReport!.entid(forTempId: "b")!
let longEntid = schemaReport!.entid(forTempId: "l")! let longEntid = schemaReport!.entid(forTempId: "l")!
@ -852,7 +853,7 @@ class MentatTests: XCTestCase {
} }
func testEntityBuilderForEntid() { func testEntityBuilderForEntid() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat) let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
let bEntid = dataReport!.entid(forTempId: "b")! let bEntid = dataReport!.entid(forTempId: "b")!
let longEntid = schemaReport!.entid(forTempId: "l")! let longEntid = schemaReport!.entid(forTempId: "l")!
@ -917,7 +918,7 @@ class MentatTests: XCTestCase {
} }
func testEntityBuilderForTempid() { func testEntityBuilderForTempid() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (schemaReport, _) = self.populateWithTypesSchema(mentat: mentat) let (schemaReport, _) = self.populateWithTypesSchema(mentat: mentat)
let longEntid = schemaReport!.entid(forTempId: "l")! let longEntid = schemaReport!.entid(forTempId: "l")!
// test that the values are as expected // test that the values are as expected
@ -964,7 +965,7 @@ class MentatTests: XCTestCase {
} }
func testInProgressBuilderTransact() { func testInProgressBuilderTransact() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat) let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = dataReport!.entid(forTempId: "a")! let aEntid = dataReport!.entid(forTempId: "a")!
let bEntid = dataReport!.entid(forTempId: "b")! let bEntid = dataReport!.entid(forTempId: "b")!
@ -1020,7 +1021,7 @@ class MentatTests: XCTestCase {
} }
func testEntityBuilderTransact() { func testEntityBuilderTransact() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat) let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
let aEntid = dataReport!.entid(forTempId: "a")! let aEntid = dataReport!.entid(forTempId: "a")!
let bEntid = dataReport!.entid(forTempId: "b")! let bEntid = dataReport!.entid(forTempId: "b")!
@ -1076,7 +1077,7 @@ class MentatTests: XCTestCase {
} }
func testEntityBuilderRetract() { func testEntityBuilderRetract() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat) let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
let bEntid = dataReport!.entid(forTempId: "b")! let bEntid = dataReport!.entid(forTempId: "b")!
let stringEntid = schemaReport!.entid(forTempId: "s")! let stringEntid = schemaReport!.entid(forTempId: "s")!
@ -1126,7 +1127,7 @@ class MentatTests: XCTestCase {
} }
func testInProgressEntityBuilderRetract() { func testInProgressEntityBuilderRetract() {
let mentat = Mentat() let mentat = try! Mentat.open()
let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat) let (schemaReport, dataReport) = self.populateWithTypesSchema(mentat: mentat)
let bEntid = dataReport!.entid(forTempId: "b")! let bEntid = dataReport!.entid(forTempId: "b")!
let stringEntid = schemaReport!.entid(forTempId: "s")! let stringEntid = schemaReport!.entid(forTempId: "s")!