|
|
@ -27,63 +27,78 @@ var protected Database.DBQueryResult resultType; |
|
|
|
var protected Database.DataType resultDataType; |
|
|
|
var protected Database.DataType resultDataType; |
|
|
|
var protected HashTable resultData; |
|
|
|
var protected HashTable resultData; |
|
|
|
var protected AcediaObject resultObject; |
|
|
|
var protected AcediaObject resultObject; |
|
|
|
|
|
|
|
var protected int resultRequestID; |
|
|
|
|
|
|
|
|
|
|
|
protected function DBReadingHandler( |
|
|
|
protected function DBReadingHandler( |
|
|
|
Database.DBQueryResult result, |
|
|
|
Database.DBQueryResult result, |
|
|
|
AcediaObject data, |
|
|
|
AcediaObject data, |
|
|
|
Database source) |
|
|
|
Database source, |
|
|
|
|
|
|
|
int requestID) |
|
|
|
{ |
|
|
|
{ |
|
|
|
default.resultType = result; |
|
|
|
default.resultType = result; |
|
|
|
default.resultObject = data; |
|
|
|
default.resultObject = data; |
|
|
|
default.resultData = HashTable(data); |
|
|
|
default.resultData = HashTable(data); |
|
|
|
|
|
|
|
default.resultRequestID = requestID; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function DBKeysHandler( |
|
|
|
protected function DBKeysHandler( |
|
|
|
Database.DBQueryResult result, |
|
|
|
Database.DBQueryResult result, |
|
|
|
ArrayList keys, |
|
|
|
ArrayList keys, |
|
|
|
Database source) |
|
|
|
Database source, |
|
|
|
|
|
|
|
int requestID) |
|
|
|
{ |
|
|
|
{ |
|
|
|
default.resultType = result; |
|
|
|
default.resultType = result; |
|
|
|
default.resultKeys = keys; |
|
|
|
default.resultKeys = keys; |
|
|
|
|
|
|
|
default.resultRequestID = requestID; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function DBCheckHandler( |
|
|
|
protected function DBCheckHandler( |
|
|
|
Database.DBQueryResult result, |
|
|
|
Database.DBQueryResult result, |
|
|
|
Database.DataType type, |
|
|
|
Database.DataType type, |
|
|
|
Database source) |
|
|
|
Database source, |
|
|
|
|
|
|
|
int requestID) |
|
|
|
{ |
|
|
|
{ |
|
|
|
default.resultType = result; |
|
|
|
default.resultType = result; |
|
|
|
default.resultDataType = type; |
|
|
|
default.resultDataType = type; |
|
|
|
|
|
|
|
default.resultRequestID = requestID; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function DBSizeHandler( |
|
|
|
protected function DBSizeHandler( |
|
|
|
Database.DBQueryResult result, |
|
|
|
Database.DBQueryResult result, |
|
|
|
int size, |
|
|
|
int size, |
|
|
|
Database source) |
|
|
|
Database source, |
|
|
|
|
|
|
|
int requestID) |
|
|
|
{ |
|
|
|
{ |
|
|
|
default.resultType = result; |
|
|
|
default.resultType = result; |
|
|
|
default.resultSize = size; |
|
|
|
default.resultSize = size; |
|
|
|
|
|
|
|
default.resultRequestID = requestID; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function DBWritingHandler( |
|
|
|
protected function DBWritingHandler( |
|
|
|
Database.DBQueryResult result, |
|
|
|
Database.DBQueryResult result, |
|
|
|
Database source) |
|
|
|
Database source, |
|
|
|
|
|
|
|
int requestID) |
|
|
|
{ |
|
|
|
{ |
|
|
|
default.resultType = result; |
|
|
|
default.resultType = result; |
|
|
|
|
|
|
|
default.resultRequestID = requestID; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function DBIncrementHandler( |
|
|
|
protected function DBIncrementHandler( |
|
|
|
Database.DBQueryResult result, |
|
|
|
Database.DBQueryResult result, |
|
|
|
Database source) |
|
|
|
Database source, |
|
|
|
|
|
|
|
int requestID) |
|
|
|
{ |
|
|
|
{ |
|
|
|
default.resultType = result; |
|
|
|
default.resultType = result; |
|
|
|
|
|
|
|
default.resultRequestID = requestID; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected function DBRemoveHandler( |
|
|
|
protected function DBRemoveHandler( |
|
|
|
Database.DBQueryResult result, |
|
|
|
Database.DBQueryResult result, |
|
|
|
Database source) |
|
|
|
Database source, |
|
|
|
|
|
|
|
int requestID) |
|
|
|
{ |
|
|
|
{ |
|
|
|
default.resultType = result; |
|
|
|
default.resultType = result; |
|
|
|
|
|
|
|
default.resultRequestID = requestID; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected static function ReadFromDB(LocalDatabaseInstance db, string pointer) |
|
|
|
protected static function ReadFromDB(LocalDatabaseInstance db, string pointer) |
|
|
@ -117,7 +132,7 @@ local LocalDatabaseInstance db; |
|
|
|
source = GetJSONTemplateString(); |
|
|
|
source = GetJSONTemplateString(); |
|
|
|
parser = __().text.ParseString(source); |
|
|
|
parser = __().text.ParseString(source); |
|
|
|
root = HashTable(__().json.ParseWith(parser)); |
|
|
|
root = HashTable(__().json.ParseWith(parser)); |
|
|
|
db = __().db.NewLocal(P("TEST_ReadOnly")); |
|
|
|
db = __core().db.NewLocal(P("TEST_ReadOnly")); |
|
|
|
db.WriteData(__().json.Pointer(), root); |
|
|
|
db.WriteData(__().json.Pointer(), root); |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
protected static function string GetJSONTemplateString() |
|
|
|
protected static function string GetJSONTemplateString() |
|
|
@ -220,19 +235,20 @@ protected static function TESTS() |
|
|
|
Test_TaskChaining(); |
|
|
|
Test_TaskChaining(); |
|
|
|
Test_Removal(); |
|
|
|
Test_Removal(); |
|
|
|
Test_Increment(); |
|
|
|
Test_Increment(); |
|
|
|
|
|
|
|
Test_RequestID(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected static function Test_LoadingPrepared() |
|
|
|
protected static function Test_LoadingPrepared() |
|
|
|
{ |
|
|
|
{ |
|
|
|
local LocalDatabaseInstance db; |
|
|
|
local LocalDatabaseInstance db; |
|
|
|
db = __().db.LoadLocal(P("TEST_ReadOnly")); |
|
|
|
db = __core().db.LoadLocal(P("TEST_ReadOnly")); |
|
|
|
Context("Testing reading prepared data from the local database."); |
|
|
|
Context("Testing reading prepared data from the local database."); |
|
|
|
Issue("Existing database reported as missing."); |
|
|
|
Issue("Existing database reported as missing."); |
|
|
|
TEST_ExpectTrue(__().db.ExistsLocal(P("TEST_ReadOnly"))); |
|
|
|
TEST_ExpectTrue(__core().db.ExistsLocal(P("TEST_ReadOnly"))); |
|
|
|
|
|
|
|
|
|
|
|
Issue("Loading same database several times produces different" |
|
|
|
Issue("Loading same database several times produces different" |
|
|
|
@ "`LocalDatabaseInstance` objects."); |
|
|
|
@ "`LocalDatabaseInstance` objects."); |
|
|
|
TEST_ExpectTrue(__().db.LoadLocal(P("TEST_ReadOnly")) == db); |
|
|
|
TEST_ExpectTrue(__core().db.LoadLocal(P("TEST_ReadOnly")) == db); |
|
|
|
// Groups of read-only tests |
|
|
|
// Groups of read-only tests |
|
|
|
SubTest_LoadingPreparedSuccessRoot(db); |
|
|
|
SubTest_LoadingPreparedSuccessRoot(db); |
|
|
|
SubTest_LoadingPreparedSuccessSubValues(db); |
|
|
|
SubTest_LoadingPreparedSuccessSubValues(db); |
|
|
@ -471,18 +487,18 @@ protected static function SubTest_LoadingPreparedGetKeysFail( |
|
|
|
protected static function Test_Writing() |
|
|
|
protected static function Test_Writing() |
|
|
|
{ |
|
|
|
{ |
|
|
|
local LocalDatabaseInstance db; |
|
|
|
local LocalDatabaseInstance db; |
|
|
|
db = __().db.NewLocal(P("TEST_DB")); |
|
|
|
db = __core().db.NewLocal(P("TEST_DB")); |
|
|
|
Context("Testing (re-)creating and writing into a new local database."); |
|
|
|
Context("Testing (re-)creating and writing into a new local database."); |
|
|
|
Issue("Cannot create a new database."); |
|
|
|
Issue("Cannot create a new database."); |
|
|
|
TEST_ExpectNotNone(db); |
|
|
|
TEST_ExpectNotNone(db); |
|
|
|
TEST_ExpectTrue(__().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
TEST_ExpectTrue(__core().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
|
|
|
|
|
|
|
|
Issue("Freshly created database is not empty."); |
|
|
|
Issue("Freshly created database is not empty."); |
|
|
|
TEST_ExpectTrue(CountRecordsInPackage("TEST_DB") == 1); // 1 root object |
|
|
|
TEST_ExpectTrue(CountRecordsInPackage("TEST_DB") == 1); // 1 root object |
|
|
|
|
|
|
|
|
|
|
|
Issue("Loading just created database produces different" |
|
|
|
Issue("Loading just created database produces different" |
|
|
|
@ "`LocalDatabaseInstance` object."); |
|
|
|
@ "`LocalDatabaseInstance` object."); |
|
|
|
TEST_ExpectTrue(__().db.LoadLocal(P("TEST_DB")) == db); |
|
|
|
TEST_ExpectTrue(__core().db.LoadLocal(P("TEST_DB")) == db); |
|
|
|
// This set of tests fills our test database with objects |
|
|
|
// This set of tests fills our test database with objects |
|
|
|
SubTest_WritingSuccess(db); |
|
|
|
SubTest_WritingSuccess(db); |
|
|
|
SubTest_WritingDataCheck(db); |
|
|
|
SubTest_WritingDataCheck(db); |
|
|
@ -495,33 +511,33 @@ protected static function Test_Writing() |
|
|
|
@ "local database."); |
|
|
|
@ "local database."); |
|
|
|
__().memory.Free(db); // For `NewLocal()` call |
|
|
|
__().memory.Free(db); // For `NewLocal()` call |
|
|
|
__().memory.Free(db); // For `LoadLocal()` call |
|
|
|
__().memory.Free(db); // For `LoadLocal()` call |
|
|
|
TEST_ExpectTrue(__().db.DeleteLocal(P("TEST_DB"))); |
|
|
|
TEST_ExpectTrue(__core().db.DeleteLocal(P("TEST_DB"))); |
|
|
|
|
|
|
|
|
|
|
|
Issue("Newly created database is reported to still exist after deletion."); |
|
|
|
Issue("Newly created database is reported to still exist after deletion."); |
|
|
|
TEST_ExpectFalse(__().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
TEST_ExpectFalse(__core().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
TEST_ExpectFalse(db.IsAllocated()); |
|
|
|
TEST_ExpectFalse(db.IsAllocated()); |
|
|
|
|
|
|
|
|
|
|
|
Issue("`DeleteLocal()` does not return `false` after trying to delete" |
|
|
|
Issue("`DeleteLocal()` does not return `false` after trying to delete" |
|
|
|
@ "non-existing local database."); |
|
|
|
@ "non-existing local database."); |
|
|
|
TEST_ExpectFalse(__().db.DeleteLocal(P("TEST_DB"))); |
|
|
|
TEST_ExpectFalse(__core().db.DeleteLocal(P("TEST_DB"))); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected static function Test_Recreate() |
|
|
|
protected static function Test_Recreate() |
|
|
|
{ |
|
|
|
{ |
|
|
|
local LocalDatabaseInstance db; |
|
|
|
local LocalDatabaseInstance db; |
|
|
|
Issue("Freshly created database is not empty."); |
|
|
|
Issue("Freshly created database is not empty."); |
|
|
|
db = __().db.NewLocal(P("TEST_DB")); |
|
|
|
db = __core().db.NewLocal(P("TEST_DB")); |
|
|
|
TEST_ExpectTrue(CountRecordsInPackage("TEST_DB") == 1); |
|
|
|
TEST_ExpectTrue(CountRecordsInPackage("TEST_DB") == 1); |
|
|
|
|
|
|
|
|
|
|
|
Issue("Cannot create a database after database with the same name was" |
|
|
|
Issue("Cannot create a database after database with the same name was" |
|
|
|
@ "just deleted."); |
|
|
|
@ "just deleted."); |
|
|
|
TEST_ExpectNotNone(db); |
|
|
|
TEST_ExpectNotNone(db); |
|
|
|
TEST_ExpectTrue(__().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
TEST_ExpectTrue(__core().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
SubTest_WritingArrayIndicies(db); |
|
|
|
SubTest_WritingArrayIndicies(db); |
|
|
|
__().db.DeleteLocal(P("TEST_DB")); |
|
|
|
__core().db.DeleteLocal(P("TEST_DB")); |
|
|
|
Issue("Newly created database is reported to still exist after deletion."); |
|
|
|
Issue("Newly created database is reported to still exist after deletion."); |
|
|
|
__().memory.Free(db); |
|
|
|
__().memory.Free(db); |
|
|
|
TEST_ExpectFalse(__().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
TEST_ExpectFalse(__core().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
TEST_ExpectFalse(db.IsAllocated()); |
|
|
|
TEST_ExpectFalse(db.IsAllocated()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -530,15 +546,15 @@ protected static function Test_TaskChaining() |
|
|
|
local LocalDatabaseInstance db; |
|
|
|
local LocalDatabaseInstance db; |
|
|
|
Context("Testing (re-)creating and writing into a new local database."); |
|
|
|
Context("Testing (re-)creating and writing into a new local database."); |
|
|
|
Issue("Freshly created database is not empty."); |
|
|
|
Issue("Freshly created database is not empty."); |
|
|
|
db = __().db.NewLocal(P("TEST_DB")); |
|
|
|
db = __core().db.NewLocal(P("TEST_DB")); |
|
|
|
TEST_ExpectTrue(CountRecordsInPackage("TEST_DB") == 1); |
|
|
|
TEST_ExpectTrue(CountRecordsInPackage("TEST_DB") == 1); |
|
|
|
|
|
|
|
|
|
|
|
Issue("Cannot create a database after database with the same name was" |
|
|
|
Issue("Cannot create a database after database with the same name was" |
|
|
|
@ "just deleted."); |
|
|
|
@ "just deleted."); |
|
|
|
TEST_ExpectNotNone(db); |
|
|
|
TEST_ExpectNotNone(db); |
|
|
|
TEST_ExpectTrue(__().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
TEST_ExpectTrue(__core().db.ExistsLocal(P("TEST_DB"))); |
|
|
|
SubTest_TaskChaining(db); |
|
|
|
SubTest_TaskChaining(db); |
|
|
|
__().db.DeleteLocal(P("TEST_DB")); |
|
|
|
__core().db.DeleteLocal(P("TEST_DB")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected static function HashTable GetJSONSubTemplateObject() |
|
|
|
protected static function HashTable GetJSONSubTemplateObject() |
|
|
@ -776,7 +792,7 @@ protected static function Test_Removal() |
|
|
|
local HashTable templateObject; |
|
|
|
local HashTable templateObject; |
|
|
|
templateObject = GetJSONSubTemplateObject(); |
|
|
|
templateObject = GetJSONSubTemplateObject(); |
|
|
|
templateArray = GetJSONSubTemplateArray(); |
|
|
|
templateArray = GetJSONSubTemplateArray(); |
|
|
|
db = __().db.NewLocal(P("TEST_DB")); |
|
|
|
db = __core().db.NewLocal(P("TEST_DB")); |
|
|
|
db.WriteData(__().json.Pointer(P("")), templateObject); |
|
|
|
db.WriteData(__().json.Pointer(P("")), templateObject); |
|
|
|
db.WriteData(__().json.Pointer(P("/B")), templateObject); |
|
|
|
db.WriteData(__().json.Pointer(P("/B")), templateObject); |
|
|
|
db.WriteData(__().json.Pointer(P("/B/A")), templateArray); |
|
|
|
db.WriteData(__().json.Pointer(P("/B/A")), templateArray); |
|
|
@ -787,7 +803,7 @@ protected static function Test_Removal() |
|
|
|
SubTest_RemovalResult(db); |
|
|
|
SubTest_RemovalResult(db); |
|
|
|
SubTest_RemovalCheckValuesAfter(db); |
|
|
|
SubTest_RemovalCheckValuesAfter(db); |
|
|
|
SubTest_RemovalRoot(db); |
|
|
|
SubTest_RemovalRoot(db); |
|
|
|
__().db.DeleteLocal(P("TEST_DB")); |
|
|
|
__core().db.DeleteLocal(P("TEST_DB")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected static function SubTest_RemovalResult(LocalDatabaseInstance db) |
|
|
|
protected static function SubTest_RemovalResult(LocalDatabaseInstance db) |
|
|
@ -861,7 +877,7 @@ protected static function Test_Increment() |
|
|
|
local HashTable templateObject; |
|
|
|
local HashTable templateObject; |
|
|
|
templateObject = GetJSONSubTemplateObject(); |
|
|
|
templateObject = GetJSONSubTemplateObject(); |
|
|
|
templateArray = GetJSONSubTemplateArray(); |
|
|
|
templateArray = GetJSONSubTemplateArray(); |
|
|
|
db = __().db.NewLocal(P("TEST_DB")); |
|
|
|
db = __core().db.NewLocal(P("TEST_DB")); |
|
|
|
db.WriteData(__().json.Pointer(P("")), templateObject); |
|
|
|
db.WriteData(__().json.Pointer(P("")), templateObject); |
|
|
|
db.WriteData(__().json.Pointer(P("/B")), templateObject); |
|
|
|
db.WriteData(__().json.Pointer(P("/B")), templateObject); |
|
|
|
db.WriteData(__().json.Pointer(P("/C")), __().box.int(-5)); |
|
|
|
db.WriteData(__().json.Pointer(P("/C")), __().box.int(-5)); |
|
|
@ -904,7 +920,7 @@ protected static function Test_Increment() |
|
|
|
Issue("Incrementing database values has created garbage objects."); |
|
|
|
Issue("Incrementing database values has created garbage objects."); |
|
|
|
// 5 initial records + 1 made for a new array in `SubTest_IncrementNull()` |
|
|
|
// 5 initial records + 1 made for a new array in `SubTest_IncrementNull()` |
|
|
|
TEST_ExpectTrue(CountRecordsInPackage("TEST_DB") == 6); |
|
|
|
TEST_ExpectTrue(CountRecordsInPackage("TEST_DB") == 6); |
|
|
|
__().db.DeleteLocal(P("TEST_DB")); |
|
|
|
__core().db.DeleteLocal(P("TEST_DB")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected static function SubTest_IncrementNull(LocalDatabaseInstance db) |
|
|
|
protected static function SubTest_IncrementNull(LocalDatabaseInstance db) |
|
|
@ -1233,7 +1249,8 @@ protected static function SubTest_IncrementRewriteArray( |
|
|
|
protected static function SubTest_IncrementMissing(LocalDatabaseInstance db) |
|
|
|
protected static function SubTest_IncrementMissing(LocalDatabaseInstance db) |
|
|
|
{ |
|
|
|
{ |
|
|
|
local DBIncrementTask task; |
|
|
|
local DBIncrementTask task; |
|
|
|
Issue("New values are created in database after incrementing with path" |
|
|
|
local DBCheckTask checkTask; |
|
|
|
|
|
|
|
Issue("New values are not created in database after incrementing with path" |
|
|
|
@ "pointing to non-existing value."); |
|
|
|
@ "pointing to non-existing value."); |
|
|
|
task = db.IncrementData(__().json.Pointer(P("/L")), __().box.int(345)); |
|
|
|
task = db.IncrementData(__().json.Pointer(P("/L")), __().box.int(345)); |
|
|
|
task.connect = DBIncrementHandler; |
|
|
|
task.connect = DBIncrementHandler; |
|
|
@ -1245,13 +1262,168 @@ protected static function SubTest_IncrementMissing(LocalDatabaseInstance db) |
|
|
|
task.connect = DBIncrementHandler; |
|
|
|
task.connect = DBIncrementHandler; |
|
|
|
task.TryCompleting(); |
|
|
|
task.TryCompleting(); |
|
|
|
TEST_ExpectTrue(default.resultType == DBR_Success); |
|
|
|
TEST_ExpectTrue(default.resultType == DBR_Success); |
|
|
|
db.CheckDataType(__().json.Pointer(P("/L"))).connect = DBCheckHandler; |
|
|
|
checkTask = db.CheckDataType(__().json.Pointer(P("/L"))); |
|
|
|
|
|
|
|
checkTask.connect = DBCheckHandler; |
|
|
|
|
|
|
|
checkTask.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultDataType == JSON_Number); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultType == DBR_Success); |
|
|
|
ReadFromDB(db, "/B/A/1/"); |
|
|
|
ReadFromDB(db, "/B/A/1/"); |
|
|
|
TEST_ExpectTrue(default.resultDataType == JSON_Number); |
|
|
|
TEST_ExpectTrue(default.resultDataType == JSON_Number); |
|
|
|
TEST_ExpectTrue(ArrayList(default.resultObject).GetLength() == 12); |
|
|
|
TEST_ExpectTrue(ArrayList(default.resultObject).GetLength() == 12); |
|
|
|
TEST_ExpectTrue(ArrayList(default.resultObject).GetInt(11) == 85); |
|
|
|
TEST_ExpectTrue(ArrayList(default.resultObject).GetInt(11) == 85); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static function Test_RequestID() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local LocalDatabaseInstance db; |
|
|
|
|
|
|
|
local ArrayList templateArray; |
|
|
|
|
|
|
|
local HashTable templateObject; |
|
|
|
|
|
|
|
templateObject = GetJSONSubTemplateObject(); |
|
|
|
|
|
|
|
templateArray = GetJSONSubTemplateArray(); |
|
|
|
|
|
|
|
db = __core().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)); |
|
|
|
|
|
|
|
db.WriteData(__().json.Pointer(P("/D")), __().box.bool(false)); |
|
|
|
|
|
|
|
db.WriteData(__().json.Pointer(P("/B/A")), templateArray); |
|
|
|
|
|
|
|
db.WriteData(__().json.Pointer(P("/B/A/1")), templateObject); |
|
|
|
|
|
|
|
db.WriteData(__().json.Pointer(P("/B/A/1/")), templateArray); |
|
|
|
|
|
|
|
/* `db` now contains: |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
"A": "simpleValue", |
|
|
|
|
|
|
|
"B": { |
|
|
|
|
|
|
|
"A": [true, { |
|
|
|
|
|
|
|
"A": "simpleValue", |
|
|
|
|
|
|
|
"B": 11.12, |
|
|
|
|
|
|
|
"": [true, null, "huh"] |
|
|
|
|
|
|
|
}, "huh"], |
|
|
|
|
|
|
|
"B": 11.12 |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
"C": -5, |
|
|
|
|
|
|
|
"D": false |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
// Constantly recreating `db` takes time, so we make test dependent |
|
|
|
|
|
|
|
// on each other. |
|
|
|
|
|
|
|
// Generally speaking this is not great, but we cannot run them in |
|
|
|
|
|
|
|
// parallel anyway. |
|
|
|
|
|
|
|
Context("Testing whether database operations report correct request ID."); |
|
|
|
|
|
|
|
SubTest_RequestIDForCheck(db); |
|
|
|
|
|
|
|
SubTest_RequestIDForIncrement(db); |
|
|
|
|
|
|
|
SubTest_RequestIDForKeys(db); |
|
|
|
|
|
|
|
SubTest_RequestIDForRead(db); |
|
|
|
|
|
|
|
SubTest_RequestIDForRemove(db); |
|
|
|
|
|
|
|
SubTest_RequestIDForSize(db); |
|
|
|
|
|
|
|
SubTest_RequestIDForWrite(db); |
|
|
|
|
|
|
|
__core().db.DeleteLocal(P("TEST_DB")); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static function SubTest_RequestIDForCheck(LocalDatabaseInstance db) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local DBCheckTask task; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Issue("Type checking operation isn't returning correct request ID."); |
|
|
|
|
|
|
|
task = db.CheckDataType(__().json.Pointer(P("/L"))); |
|
|
|
|
|
|
|
task.connect = DBCheckHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == 0); |
|
|
|
|
|
|
|
task = db.CheckDataType(__().json.Pointer(P("/L")), 29); |
|
|
|
|
|
|
|
task.connect = DBCheckHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == 29); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static function SubTest_RequestIDForIncrement( |
|
|
|
|
|
|
|
LocalDatabaseInstance db) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local DBIncrementTask task; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Issue("Increment operation isn't returning correct request ID."); |
|
|
|
|
|
|
|
task = db.IncrementData(__().json.Pointer(P("/L")), __().box.int(29)); |
|
|
|
|
|
|
|
task.connect = DBIncrementHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == 0); |
|
|
|
|
|
|
|
task = db.IncrementData(__().json.Pointer(P("/L")), __().box.int(29), -7); |
|
|
|
|
|
|
|
task.connect = DBIncrementHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == -7); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static function SubTest_RequestIDForKeys(LocalDatabaseInstance db) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local DBKeysTask task; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Issue("Keys list operation isn't returning correct request ID."); |
|
|
|
|
|
|
|
task = db.GetDataKeys(__().json.Pointer(P(""))); |
|
|
|
|
|
|
|
task.connect = DBKeysHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == 0); |
|
|
|
|
|
|
|
task = db.GetDataKeys(__().json.Pointer(P("")), 11); |
|
|
|
|
|
|
|
task.connect = DBKeysHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == 11); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static function SubTest_RequestIDForRead(LocalDatabaseInstance db) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local DBReadTask task; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Issue("Reading operation isn't returning correct request ID."); |
|
|
|
|
|
|
|
task = db.ReadData(__().json.Pointer(P("/L")),); |
|
|
|
|
|
|
|
task.connect = DBReadingHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == 0); |
|
|
|
|
|
|
|
task = db.ReadData(__().json.Pointer(P("/L")),, 666); |
|
|
|
|
|
|
|
task.connect = DBReadingHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == 666); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static function SubTest_RequestIDForRemove(LocalDatabaseInstance db) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local DBRemoveTask task; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Issue("Removing operation isn't returning correct request ID."); |
|
|
|
|
|
|
|
task = db.RemoveData(__().json.Pointer(P("/L"))); |
|
|
|
|
|
|
|
task.connect = DBRemoveHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == 0); |
|
|
|
|
|
|
|
task = db.RemoveData(__().json.Pointer(P("/L")), 80); |
|
|
|
|
|
|
|
task.connect = DBRemoveHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == 80); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static function SubTest_RequestIDForSize(LocalDatabaseInstance db) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local DBSizeTask task; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Issue("Size getting operation isn't returning correct request ID."); |
|
|
|
|
|
|
|
task = db.GetDataSize(__().json.Pointer(P("/L"))); |
|
|
|
|
|
|
|
task.connect = DBSizeHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == 0); |
|
|
|
|
|
|
|
task = db.GetDataSize(__().json.Pointer(P("/L")), 7); |
|
|
|
|
|
|
|
task.connect = DBSizeHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == 7); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected static function SubTest_RequestIDForWrite(LocalDatabaseInstance db) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
local DBWriteTask task; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Issue("Writing operation isn't returning correct request ID."); |
|
|
|
|
|
|
|
task = db.WriteData(__().json.Pointer(P("/L")), none); |
|
|
|
|
|
|
|
task.connect = DBWritingHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == 0); |
|
|
|
|
|
|
|
task = db.WriteData(__().json.Pointer(P("/L")), none, 42); |
|
|
|
|
|
|
|
task.connect = DBWritingHandler; |
|
|
|
|
|
|
|
task.TryCompleting(); |
|
|
|
|
|
|
|
TEST_ExpectTrue(default.resultRequestID == 42); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
defaultproperties |
|
|
|
defaultproperties |
|
|
|
{ |
|
|
|
{ |
|
|
|
caseGroup = "Database" |
|
|
|
caseGroup = "Database" |
|
|
|