|
|
|
@ -132,7 +132,7 @@ local LocalDatabaseInstance db;
|
|
|
|
|
source = GetJSONTemplateString(); |
|
|
|
|
parser = __().text.ParseString(source); |
|
|
|
|
root = HashTable(__().json.ParseWith(parser)); |
|
|
|
|
db = __core().db.NewLocal(P("TEST_ReadOnly")); |
|
|
|
|
db = __level().db.NewLocal(P("TEST_ReadOnly")); |
|
|
|
|
db.WriteData(__().json.Pointer(), root); |
|
|
|
|
*/ |
|
|
|
|
protected static function string GetJSONTemplateString() |
|
|
|
@ -241,14 +241,14 @@ protected static function TESTS()
|
|
|
|
|
protected static function Test_LoadingPrepared() |
|
|
|
|
{ |
|
|
|
|
local LocalDatabaseInstance db; |
|
|
|
|
db = __core().db.LoadLocal(P("TEST_ReadOnly")); |
|
|
|
|
db = __level().db.LoadLocal(P("TEST_ReadOnly")); |
|
|
|
|
Context("Testing reading prepared data from the local database."); |
|
|
|
|
Issue("Existing database reported as missing."); |
|
|
|
|
TEST_ExpectTrue(__core().db.ExistsLocal(P("TEST_ReadOnly"))); |
|
|
|
|
TEST_ExpectTrue(__level().db.ExistsLocal(P("TEST_ReadOnly"))); |
|
|
|
|
|
|
|
|
|
Issue("Loading same database several times produces different" |
|
|
|
|
@ "`LocalDatabaseInstance` objects."); |
|
|
|
|
TEST_ExpectTrue(__core().db.LoadLocal(P("TEST_ReadOnly")) == db); |
|
|
|
|
TEST_ExpectTrue(__level().db.LoadLocal(P("TEST_ReadOnly")) == db); |
|
|
|
|
// Groups of read-only tests |
|
|
|
|
SubTest_LoadingPreparedSuccessRoot(db); |
|
|
|
|
SubTest_LoadingPreparedSuccessSubValues(db); |
|
|
|
@ -487,18 +487,18 @@ protected static function SubTest_LoadingPreparedGetKeysFail(
|
|
|
|
|
protected static function Test_Writing() |
|
|
|
|
{ |
|
|
|
|
local LocalDatabaseInstance db; |
|
|
|
|
db = __core().db.NewLocal(P("TEST_DB")); |
|
|
|
|
db = __level().db.NewLocal(P("TEST_DB")); |
|
|
|
|
Context("Testing (re-)creating and writing into a new local database."); |
|
|
|
|
Issue("Cannot create a new database."); |
|
|
|
|
TEST_ExpectNotNone(db); |
|
|
|
|
TEST_ExpectTrue(__core().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
|
TEST_ExpectTrue(__level().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
|
|
|
|
|
|
Issue("Freshly created database is not empty."); |
|
|
|
|
TEST_ExpectTrue(CountRecordsInPackage("TEST_DB") == 1); // 1 root object |
|
|
|
|
|
|
|
|
|
Issue("Loading just created database produces different" |
|
|
|
|
@ "`LocalDatabaseInstance` object."); |
|
|
|
|
TEST_ExpectTrue(__core().db.LoadLocal(P("TEST_DB")) == db); |
|
|
|
|
TEST_ExpectTrue(__level().db.LoadLocal(P("TEST_DB")) == db); |
|
|
|
|
// This set of tests fills our test database with objects |
|
|
|
|
SubTest_WritingSuccess(db); |
|
|
|
|
SubTest_WritingDataCheck(db); |
|
|
|
@ -511,33 +511,33 @@ protected static function Test_Writing()
|
|
|
|
|
@ "local database."); |
|
|
|
|
__().memory.Free(db); // For `NewLocal()` call |
|
|
|
|
__().memory.Free(db); // For `LoadLocal()` call |
|
|
|
|
TEST_ExpectTrue(__core().db.DeleteLocal(P("TEST_DB"))); |
|
|
|
|
TEST_ExpectTrue(__level().db.DeleteLocal(P("TEST_DB"))); |
|
|
|
|
|
|
|
|
|
Issue("Newly created database is reported to still exist after deletion."); |
|
|
|
|
TEST_ExpectFalse(__core().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
|
TEST_ExpectFalse(__level().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
|
TEST_ExpectFalse(db.IsAllocated()); |
|
|
|
|
|
|
|
|
|
Issue("`DeleteLocal()` does not return `false` after trying to delete" |
|
|
|
|
@ "non-existing local database."); |
|
|
|
|
TEST_ExpectFalse(__core().db.DeleteLocal(P("TEST_DB"))); |
|
|
|
|
TEST_ExpectFalse(__level().db.DeleteLocal(P("TEST_DB"))); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected static function Test_Recreate() |
|
|
|
|
{ |
|
|
|
|
local LocalDatabaseInstance db; |
|
|
|
|
Issue("Freshly created database is not empty."); |
|
|
|
|
db = __core().db.NewLocal(P("TEST_DB")); |
|
|
|
|
db = __level().db.NewLocal(P("TEST_DB")); |
|
|
|
|
TEST_ExpectTrue(CountRecordsInPackage("TEST_DB") == 1); |
|
|
|
|
|
|
|
|
|
Issue("Cannot create a database after database with the same name was" |
|
|
|
|
@ "just deleted."); |
|
|
|
|
TEST_ExpectNotNone(db); |
|
|
|
|
TEST_ExpectTrue(__core().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
|
TEST_ExpectTrue(__level().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
|
SubTest_WritingArrayIndicies(db); |
|
|
|
|
__core().db.DeleteLocal(P("TEST_DB")); |
|
|
|
|
__level().db.DeleteLocal(P("TEST_DB")); |
|
|
|
|
Issue("Newly created database is reported to still exist after deletion."); |
|
|
|
|
__().memory.Free(db); |
|
|
|
|
TEST_ExpectFalse(__core().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
|
TEST_ExpectFalse(__level().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
|
TEST_ExpectFalse(db.IsAllocated()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -546,15 +546,15 @@ protected static function Test_TaskChaining()
|
|
|
|
|
local LocalDatabaseInstance db; |
|
|
|
|
Context("Testing (re-)creating and writing into a new local database."); |
|
|
|
|
Issue("Freshly created database is not empty."); |
|
|
|
|
db = __core().db.NewLocal(P("TEST_DB")); |
|
|
|
|
db = __level().db.NewLocal(P("TEST_DB")); |
|
|
|
|
TEST_ExpectTrue(CountRecordsInPackage("TEST_DB") == 1); |
|
|
|
|
|
|
|
|
|
Issue("Cannot create a database after database with the same name was" |
|
|
|
|
@ "just deleted."); |
|
|
|
|
TEST_ExpectNotNone(db); |
|
|
|
|
TEST_ExpectTrue(__core().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
|
TEST_ExpectTrue(__level().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
|
SubTest_TaskChaining(db); |
|
|
|
|
__core().db.DeleteLocal(P("TEST_DB")); |
|
|
|
|
__level().db.DeleteLocal(P("TEST_DB")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected static function HashTable GetJSONSubTemplateObject() |
|
|
|
@ -792,7 +792,7 @@ protected static function Test_Removal()
|
|
|
|
|
local HashTable templateObject; |
|
|
|
|
templateObject = GetJSONSubTemplateObject(); |
|
|
|
|
templateArray = GetJSONSubTemplateArray(); |
|
|
|
|
db = __core().db.NewLocal(P("TEST_DB")); |
|
|
|
|
db = __level().db.NewLocal(P("TEST_DB")); |
|
|
|
|
db.WriteData(__().json.Pointer(P("")), templateObject); |
|
|
|
|
db.WriteData(__().json.Pointer(P("/B")), templateObject); |
|
|
|
|
db.WriteData(__().json.Pointer(P("/B/A")), templateArray); |
|
|
|
@ -803,7 +803,7 @@ protected static function Test_Removal()
|
|
|
|
|
SubTest_RemovalResult(db); |
|
|
|
|
SubTest_RemovalCheckValuesAfter(db); |
|
|
|
|
SubTest_RemovalRoot(db); |
|
|
|
|
__core().db.DeleteLocal(P("TEST_DB")); |
|
|
|
|
__level().db.DeleteLocal(P("TEST_DB")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected static function SubTest_RemovalResult(LocalDatabaseInstance db) |
|
|
|
@ -877,7 +877,7 @@ protected static function Test_Increment()
|
|
|
|
|
local HashTable templateObject; |
|
|
|
|
templateObject = GetJSONSubTemplateObject(); |
|
|
|
|
templateArray = GetJSONSubTemplateArray(); |
|
|
|
|
db = __core().db.NewLocal(P("TEST_DB")); |
|
|
|
|
db = __level().db.NewLocal(P("TEST_DB")); |
|
|
|
|
db.WriteData(__().json.Pointer(P("")), templateObject); |
|
|
|
|
db.WriteData(__().json.Pointer(P("/B")), templateObject); |
|
|
|
|
db.WriteData(__().json.Pointer(P("/C")), __().box.int(-5)); |
|
|
|
@ -920,7 +920,7 @@ protected static function Test_Increment()
|
|
|
|
|
Issue("Incrementing database values has created garbage objects."); |
|
|
|
|
// 5 initial records + 1 made for a new array in `SubTest_IncrementNull()` |
|
|
|
|
TEST_ExpectTrue(CountRecordsInPackage("TEST_DB") == 6); |
|
|
|
|
__core().db.DeleteLocal(P("TEST_DB")); |
|
|
|
|
__level().db.DeleteLocal(P("TEST_DB")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected static function SubTest_IncrementNull(LocalDatabaseInstance db) |
|
|
|
@ -1280,7 +1280,7 @@ protected static function Test_RequestID()
|
|
|
|
|
local HashTable templateObject; |
|
|
|
|
templateObject = GetJSONSubTemplateObject(); |
|
|
|
|
templateArray = GetJSONSubTemplateArray(); |
|
|
|
|
db = __core().db.NewLocal(P("TEST_DB")); |
|
|
|
|
db = __level().db.NewLocal(P("TEST_DB")); |
|
|
|
|
db.WriteData(__().json.Pointer(P("")), templateObject); |
|
|
|
|
db.WriteData(__().json.Pointer(P("/B")), templateObject); |
|
|
|
|
db.WriteData(__().json.Pointer(P("/C")), __().box.int(-5)); |
|
|
|
@ -1315,7 +1315,7 @@ protected static function Test_RequestID()
|
|
|
|
|
SubTest_RequestIDForRemove(db); |
|
|
|
|
SubTest_RequestIDForSize(db); |
|
|
|
|
SubTest_RequestIDForWrite(db); |
|
|
|
|
__core().db.DeleteLocal(P("TEST_DB")); |
|
|
|
|
__level().db.DeleteLocal(P("TEST_DB")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
protected static function SubTest_RequestIDForCheck(LocalDatabaseInstance db) |
|
|
|
|