-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests for new migration from RLMObject to RLMEmbeddedObject #7094
Conversation
@@ -1398,6 +1398,390 @@ - (void)testModifyPrimaryKeyInMigration { | |||
} | |||
} | |||
|
|||
- (void)testChangeEmptyTableFromTopLevelToEmbedded { | |||
RLMProperty *intProperty = [[RLMProperty alloc] initWithName:@"intProperty" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than manually defining the base schema, this should just define a normal subclass and use that for the initial schema (or reuse an existing type if possible). The general pattern these tests should take is obtain schema from classes with schemaForObjectClass:
, mutate a second copy of the schema to match the thing being tested, then call assertMigrationRequiredForChangeFrom:to:
which initializes the Realm with the initial schema, verifies that the schema version has to be bumped to migrate to the new schema, and then verifies that the tables are in the correct state after migrating to the new schema.
The tests which actually have a migration block should use createTestRealmWithSchema :
+ migrateTestRealmWithBlock:
XCTAssertNotNil(oldObject); | ||
XCTAssertNotNil(newObject); | ||
XCTAssertEqual(oldObject[@"childProperty"][@"intProperty"], newObject[@"childProperty"][@"intProperty"]); | ||
XCTAssert([newObject[@"childProperty"][@"intProperty"] intValue] == 42 || [newObject[@"childProperty"][@"intProperty"] intValue] == 43); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should read the value to a local variable rather than duplicating all that stuff.
XCTAssertNotNil(oldObject); | ||
XCTAssertNotNil(newObject); | ||
XCTAssertEqual([oldObject[@"intProperty"] intValue], [newObject[@"intProperty"] intValue]); | ||
XCTAssert([newObject[@"intProperty"] intValue] == 42); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
XCTAssertEqual
Tests on our side for the changed
embedded table
functionality introduced by realm/realm-core#4414.