mirror of
https://github.com/status-im/realm-js.git
synced 2025-01-11 06:46:03 +00:00
minimal tests for migrations
This commit is contained in:
parent
aa035717a5
commit
8ad1b0907d
@ -403,6 +403,21 @@ JSValueRef RealmAddNotification(JSContextRef ctx, JSObjectRef function, JSObject
|
||||
}
|
||||
}
|
||||
|
||||
JSValueRef RealmClose(JSContextRef ctx, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* jsException) {
|
||||
try {
|
||||
RJSValidateArgumentCount(argumentCount, 0);
|
||||
SharedRealm realm = *RJSGetInternal<SharedRealm *>(thisObject);
|
||||
realm->invalidate();
|
||||
realm::Realm::s_global_cache.remove(realm->config().path, realm->thread_id());
|
||||
}
|
||||
catch (std::exception &exp) {
|
||||
if (jsException) {
|
||||
*jsException = RJSMakeError(ctx, exp);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void RJSNotificationFinalize(JSObjectRef object) {
|
||||
Notification *notification = RJSGetInternal<Notification *>(object);
|
||||
JSGlobalContextRelease(notification->ctx);
|
||||
@ -416,6 +431,7 @@ const JSStaticFunction RJSRealmFuncs[] = {
|
||||
{"deleteAll", RealmDeleteAll, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
|
||||
{"write", RealmWrite, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
|
||||
{"addNotification", RealmAddNotification, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
|
||||
{"close", RealmClose, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
||||
|
@ -92,7 +92,9 @@ static JSClassRef s_globalClass;
|
||||
realm::Realm::s_global_cache.invalidate_all();
|
||||
realm::Realm::s_global_cache.clear();
|
||||
|
||||
DeleteRealmFilesAtPath(TestRealmPath());
|
||||
DeleteRealmFilesAtPath(RealmPathForFile(@"test.realm"));
|
||||
DeleteRealmFilesAtPath(RealmPathForFile(@"test1.realm"));
|
||||
DeleteRealmFilesAtPath(RealmPathForFile(@"test2.realm"));
|
||||
DeleteRealmFilesAtPath(@(RJSDefaultPath().c_str()));
|
||||
|
||||
[super tearDown];
|
||||
|
@ -54,6 +54,18 @@ var RealmTests = {
|
||||
var testPath = TestUtil.realmPathForFile('test1.realm');
|
||||
var realm = new Realm({path: testPath, schema: [], schemaVersion: 1});
|
||||
TestCase.assertEqual(realm.schemaVersion, 1);
|
||||
//TestCase.assertEqual(realm.schema.length, 0);
|
||||
|
||||
realm.close();
|
||||
// TestCase.assertThrows(function() {
|
||||
// realm = new Realm({path: testPath, schema: [TestObjectSchema], schemaVersion: 1});
|
||||
// }, "schema changes require updating the schema version");
|
||||
|
||||
realm = new Realm({path: testPath, schema: [TestObjectSchema], schemaVersion: 2});
|
||||
realm.write(function() {
|
||||
realm.create('TestObject', [1]);
|
||||
});
|
||||
TestCase.assertEqual(realm.objects('TestObject')[0].doubleCol, 1)
|
||||
|
||||
//realm = undefined;
|
||||
//realm = new Realm({path: testPath, schema: [], schemaVersion: 2});
|
||||
|
Loading…
x
Reference in New Issue
Block a user