未验证 提交 5ce1b41c 编写于 作者: O openharmony_ci 提交者: Gitee

!7055 【distributeddatamgr】【monthly】SingleKvStoreKVPromiseJsTest.js 用例优化

Merge pull request !7055 from wuxiaodan/monthly_20221018
...@@ -773,21 +773,16 @@ describe('SingleKvStoreCallbackTest', function () { ...@@ -773,21 +773,16 @@ describe('SingleKvStoreCallbackTest', function () {
* @tc.name Test Js Api SingleKvStore.Delete() testcase 001 * @tc.name Test Js Api SingleKvStore.Delete() testcase 001
*/ */
it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700', 0, async function (done) {
console.log('SingleKvStoreDeletePredicatesCallbackTest001'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700');
try { try {
let predicates = new dataShare.DataSharePredicates(); await kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) {
await kvStore.delete(predicates, function (err,data) { console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700 delete err: ' + err);
if (err == undefined) { expect(err == undefined).assertTrue();
console.log('SingleKvStoreDeletePredicatesCallbackTest001 delete success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700 expect fin');
expect(null).assertFail();
} else {
console.error('SingleKvStoreDeletePredicatesCallbackTest001 delete fail' + err`, error code is ${err.code}, message is ${err.message}`);
expect(err != undefined).assertTrue();
}
done(); done();
}); });
}catch(e) { }catch(e) {
console.error('SingleKvStoreDeletePredicatesCallbackTest001 e' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700 e' + `, error code is ${e.code}, message is ${e.message}`);
expect(e.code == 401).assertTrue(); expect(e.code == 401).assertTrue();
done(); done();
} }
...@@ -802,13 +797,10 @@ describe('SingleKvStoreCallbackTest', function () { ...@@ -802,13 +797,10 @@ describe('SingleKvStoreCallbackTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2800', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2800', 0, async function (done) {
console.log('SingleKvStoreDeletePredicatesCallbackTest002'); console.log('SingleKvStoreDeletePredicatesCallbackTest002');
try { try {
let predicates = new dataShare.DataSharePredicates();
let arr = ["name"];
predicates.inKeys(arr);
await kvStore.put("name", "Bob", async function (err, data) { await kvStore.put("name", "Bob", async function (err, data) {
console.log('SingleKvStoreDeletePredicatesCallbackTest002 put success'); console.log('SingleKvStoreDeletePredicatesCallbackTest002 put success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
await kvStore.delete(predicates, function (err,data) { await kvStore.delete("name", function (err,data) {
console.log('SingleKvStoreDeletePredicatesCallbackTest002 delete success'); console.log('SingleKvStoreDeletePredicatesCallbackTest002 delete success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
done(); done();
...@@ -828,23 +820,20 @@ describe('SingleKvStoreCallbackTest', function () { ...@@ -828,23 +820,20 @@ describe('SingleKvStoreCallbackTest', function () {
* @tc.name Test Js Api SingleKvStore.Delete() testcase 003 * @tc.name Test Js Api SingleKvStore.Delete() testcase 003
*/ */
it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900', 0, async function (done) {
console.log('SingleKvStoreDeletePredicatesCallbackTest003'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900');
try { try {
let predicates = new dataShare.DataSharePredicates();
let arr = [null]; let arr = [null];
predicates.inKeys(arr);
await kvStore.put("name", "Bob", async function (err, data) { await kvStore.put("name", "Bob", async function (err, data) {
console.log('SingleKvStoreDeletePredicatesCallbackTest003 put success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900 put success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
await kvStore.delete(predicates, function (err,data) { console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900 expect finash');
console.log('SingleKvStoreDeletePredicatesCallbackTest003 delete success: '+err);
expect(err == undefined).assertTrue();
done();
});
}) })
await kvStore.delete(arr, function (err,data) {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900 delete success: '+err);
});
} catch(e) { } catch(e) {
console.error('SingleKvStoreDeletePredicatesCallbackTest003 e' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900 e' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail(); expect(e.code == 401).assertTrue();
done(); done();
} }
}) })
...@@ -2228,8 +2217,8 @@ describe('SingleKvStoreCallbackTest', function () { ...@@ -2228,8 +2217,8 @@ describe('SingleKvStoreCallbackTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULT_CALLBACK_7800', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULT_CALLBACK_7800', 0, async function (done) {
console.log('SingleKvStoreGetResultSetPredicatesCallbackTest001'); console.log('SingleKvStoreGetResultSetPredicatesCallbackTest001');
try { try {
let predicates = new dataShare.DataSharePredicates(); let query = new factory.Query();
await kvStore.getResultSet(predicates).then((result) => { await kvStore.getResultSet(query).then((result) => {
console.log('SingleKvStoreGetResultSetPredicatesCallbackTest001 getResultSet success'); console.log('SingleKvStoreGetResultSetPredicatesCallbackTest001 getResultSet success');
}).catch((err) => { }).catch((err) => {
console.error('SingleKvStoreGetResultSetPredicatesCallbackTest001 getResultSet fail ' + err`, error code is ${err.code}, message is ${err.message}`); console.error('SingleKvStoreGetResultSetPredicatesCallbackTest001 getResultSet fail ' + err`, error code is ${err.code}, message is ${err.message}`);
......
...@@ -771,17 +771,16 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -771,17 +771,16 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100', 0, async function (done) {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100');
try { try {
let predicates = new dataShare.DataSharePredicates(); await kvStore.delete("KEY_TEST_STRING_ELEMENTS").then((data) => {
await kvStore.delete(predicates).then((data) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 delete success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 delete success');
expect(null).assertFail(); expect(data == undefined).assertTrue();
}).catch((err) => { }).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 delete fail ' + `, error code is ${err.code}, message is ${err.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 delete fail err ' + err);
expect(err != undefined).assertTrue(); expect(null).assertFail();
}); });
}catch(e) { }catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 e' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 e' + `, error code is ${e.code}, message is ${e.message}`);
expect(e.code == 401).assertTrue(); expect(null).assertFail();
} }
done(); done();
}) })
...@@ -795,13 +794,10 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -795,13 +794,10 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200', 0, async function (done) {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200');
try { try {
let predicates = new dataShare.DataSharePredicates();
let arr = ["name"];
predicates.inKeys(arr);
await kvStore.put("name", "Bob").then(async (data) => { await kvStore.put("name", "Bob").then(async (data) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200 put success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200 put success');
expect(data == undefined).assertTrue(); expect(data == undefined).assertTrue();
await kvStore.delete(predicates).then((data) => { await kvStore.delete("name").then((data) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200 delete success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200 delete success');
expect(data == undefined).assertTrue(); expect(data == undefined).assertTrue();
}).catch((err) => { }).catch((err) => {
...@@ -828,22 +824,23 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -828,22 +824,23 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300', 0, async function (done) {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300');
try { try {
let predicates = new dataShare.DataSharePredicates();
let arr = [null]; await kvStore.put("number", "123").then(async (data) => {
predicates.inKeys(arr);
await kvStore.put("name", "Bob").then(async (data) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 put success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 put success');
expect(data == undefined).assertTrue();
await kvStore.delete("number").then((data) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 delete success');
expect(data == undefined).assertTrue();
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
});
}).catch((err) => { }).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 put fail ' + `, error code is ${err.code}, message is ${err.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail(); expect(null).assertFail();
}); });
await kvStore.delete(predicates, function (err,data) { } catch (e) {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 delete success'); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 put e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(err != undefined).assertTrue();
done();
});
}catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 e' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
...@@ -858,7 +855,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -858,7 +855,7 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0100', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0100', 0, async function (done) {
try { try {
kvStore.on('dataChange', 0, function (data) { kvStore.on('dataChange', 0, function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0100 ' + JSON.stringify(data)); console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0100 dataChange'+ JSON.stringify(data));
expect(data != null).assertTrue(); expect(data != null).assertTrue();
}); });
await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => { await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => {
...@@ -884,7 +881,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -884,7 +881,7 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0200', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0200', 0, async function (done) {
try { try {
kvStore.on('dataChange', 1, function (data) { kvStore.on('dataChange', 1, function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0200 on ' + JSON.stringify(data)); console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0200 dataChange' + JSON.stringify(data));
expect(data != null).assertTrue(); expect(data != null).assertTrue();
}); });
await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => { await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => {
...@@ -910,7 +907,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -910,7 +907,7 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0300', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0300', 0, async function (done) {
try { try {
kvStore.on('dataChange', 2, function (data) { kvStore.on('dataChange', 2, function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0300 ' + JSON.stringify(data)); console.info('SUB_DDM_DKV_SINGLEKVSTORE_ONCHANGE_PROMISE_0300 dataChange' + JSON.stringify(data));
expect(data != null).assertTrue(); expect(data != null).assertTrue();
}); });
await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => { await kvStore.put(KEY_TEST_FLOAT_ELEMENT, VALUE_TEST_FLOAT_ELEMENT).then((data) => {
...@@ -952,6 +949,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -952,6 +949,7 @@ describe('SingleKvStorePromiseTest', function () {
kvStore.sync(syncDeviceIds, mode, 10); kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) { } catch (e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail();
} }
}catch(e) { }catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0100 e ' + `, error code is ${e.code}, message is ${e.message}`);
...@@ -985,6 +983,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -985,6 +983,7 @@ describe('SingleKvStorePromiseTest', function () {
kvStore.sync(syncDeviceIds, mode, 10); kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) { } catch (e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail();
} }
}catch(e) { }catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
...@@ -1018,6 +1017,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1018,6 +1017,7 @@ describe('SingleKvStorePromiseTest', function () {
kvStore.sync(syncDeviceIds, mode, 10); kvStore.sync(syncDeviceIds, mode, 10);
} catch (e) { } catch (e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 sync no peer device :e:' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail();
} }
}catch(e) { }catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_ONSYNCCOMPLETE_PROMISE_0300 e ' + `, error code is ${e.code}, message is ${e.message}`);
...@@ -1036,7 +1036,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1036,7 +1036,7 @@ describe('SingleKvStorePromiseTest', function () {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0100'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0100');
try { try {
var func = function (data) { var func = function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0100 ' + JSON.stringify(data)); console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0100 dataChange' + JSON.stringify(data));
}; };
kvStore.on('dataChange', 0, func); kvStore.on('dataChange', 0, func);
kvStore.off('dataChange', func); kvStore.off('dataChange', func);
...@@ -1058,10 +1058,10 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1058,10 +1058,10 @@ describe('SingleKvStorePromiseTest', function () {
let ret = false; let ret = false;
try { try {
var func = function (data) { var func = function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0200 ' + JSON.stringify(data)); console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0200 dataChange' + JSON.stringify(data));
}; };
var func1 = function (data) { var func1 = function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0200 ' + JSON.stringify(data)); console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0200 dataChange1' + JSON.stringify(data));
}; };
kvStore.on('dataChange', 0, func); kvStore.on('dataChange', 0, func);
kvStore.on('dataChange', 0, func1); kvStore.on('dataChange', 0, func1);
...@@ -1083,10 +1083,10 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1083,10 +1083,10 @@ describe('SingleKvStorePromiseTest', function () {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0300'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0300');
try { try {
var func = function (data) { var func = function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0300 0' + data) console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0300 dataChange' + data)
}; };
var func1 = function (data) { var func1 = function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0300 0' + data) console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0300 dataChange1' + data)
}; };
kvStore.on('dataChange', 0, func); kvStore.on('dataChange', 0, func);
kvStore.on('dataChange', 0, func1); kvStore.on('dataChange', 0, func1);
...@@ -1109,7 +1109,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1109,7 +1109,7 @@ describe('SingleKvStorePromiseTest', function () {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0400'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0400');
try { try {
var func = function (data) { var func = function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0400 ' + JSON.stringify(data)); console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFCHANGE_PROMISE_0400 dataChange' + JSON.stringify(data));
}; };
kvStore.on('dataChange', 0, func); kvStore.on('dataChange', 0, func);
kvStore.off('dataChange'); kvStore.off('dataChange');
...@@ -1130,7 +1130,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1130,7 +1130,7 @@ describe('SingleKvStorePromiseTest', function () {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100');
try { try {
var func = function (data) { var func = function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100 0' + data) console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0100 syncComplete' + data)
}; };
kvStore.on('syncComplete', func); kvStore.on('syncComplete', func);
kvStore.off('syncComplete', func); kvStore.off('syncComplete', func);
...@@ -1151,10 +1151,10 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1151,10 +1151,10 @@ describe('SingleKvStorePromiseTest', function () {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200');
try { try {
var func = function (data) { var func = function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200 0' + data) console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200 syncComplete' + data)
}; };
var func1 = function (data) { var func1 = function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200 0' + data) console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0200 syncComplete1' + data)
}; };
kvStore.on('syncComplete', func); kvStore.on('syncComplete', func);
kvStore.on('syncComplete', func1); kvStore.on('syncComplete', func1);
...@@ -1176,10 +1176,10 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1176,10 +1176,10 @@ describe('SingleKvStorePromiseTest', function () {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300');
try { try {
var func = function (data) { var func = function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300 0' + data) console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300 syncComplete' + data)
}; };
var func1 = function (data) { var func1 = function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300 0' + data) console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0300 syncComplete1' + data)
}; };
kvStore.on('syncComplete', func); kvStore.on('syncComplete', func);
kvStore.on('syncComplete', func1); kvStore.on('syncComplete', func1);
...@@ -1202,7 +1202,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1202,7 +1202,7 @@ describe('SingleKvStorePromiseTest', function () {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400');
try { try {
var func = function (data) { var func = function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400 0' + data) console.info('SUB_DDM_DKV_SINGLEKVSTORE_OFFSYNCCOMPLETE_PROMISE_0400 syncComplete' + data)
}; };
kvStore.on('syncComplete', func); kvStore.on('syncComplete', func);
kvStore.off('syncComplete'); kvStore.off('syncComplete');
...@@ -1228,7 +1228,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1228,7 +1228,7 @@ describe('SingleKvStorePromiseTest', function () {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 setSyncRange success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 setSyncRange success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
}).catch((err) => { }).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETESTRING_PROMISE_0300 delete fail ' + `, error code is ${err.code}, message is ${err.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0100 fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail(); expect(null).assertFail();
}); });
}catch(e) { }catch(e) {
...@@ -1253,7 +1253,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1253,7 +1253,7 @@ describe('SingleKvStorePromiseTest', function () {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200 setSyncRange success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200 setSyncRange success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
}).catch((err) => { }).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200 delete fail ' + `, error code is ${err.code}, message is ${err.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0200 fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail(); expect(null).assertFail();
}); });
}catch(e) { }catch(e) {
...@@ -1278,7 +1278,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1278,7 +1278,7 @@ describe('SingleKvStorePromiseTest', function () {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300 setSyncRange success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300 setSyncRange success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
}).catch((err) => { }).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300 delete fail ' + `, error code is ${err.code}, message is ${err.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_SETSYNCRANGE_PROMISE_0300 fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail(); expect(null).assertFail();
}); });
}catch(e) { }catch(e) {
...@@ -1553,24 +1553,29 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1553,24 +1553,29 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100');
try { try {
let values = []; let entries = [];
let arr1 = new Uint8Array([4,5,6,7]); for (var i = 0; i < 10; i++) {
let arr2 = new Uint8Array([4,5,6,7,8]); var key = 'batch_test_number_key';
let vb1 = {key : "name_1", value : arr1}; var entry = {
let vb2 = {key : "name_2", value : arr2}; key : key + i,
values.push(vb1); value : {
values.push(vb2); type : factory.ValueType.DOUBLE,
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 values: ' + JSON.stringify(values)); value : 2.00
await kvStore.putBatch(values).then(async (err) => { }
}
entries.push(entry);
}
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 entries: ' + JSON.stringify(entries));
await kvStore.putBatch(entries).then(async (err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 putBatch success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 putBatch success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
var query = new factory.Query(); var query = new factory.Query();
query.prefixKey("name_"); query.prefixKey("batch_test_");
await kvStore.getEntries(query).then((entrys) => { await kvStore.getEntries(query).then((entrys) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 getEntries success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 getEntries success');
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 entrys.length: ' + entrys.length); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 entrys.length: ' + entrys.length);
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 entrys[0]: ' + JSON.stringify(entrys[1])); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 entrys[0]: ' + JSON.stringify(entrys[0]));
expect(entrys.length == 2).assertTrue(); expect(entrys.length == 10).assertTrue();
done(); done();
}); });
}); });
...@@ -1590,22 +1595,29 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1590,22 +1595,29 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200');
try { try {
let values = []; let entries = [];
let vb1 = {key : "name_1", value : "arr1"}; for (var i = 0; i < 10; i++) {
let vb2 = {key : "name_2", value : "arr2"}; var key = 'key_test_int';
values.push(vb1); var entry = {
values.push(vb2); key: key + i,
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 values: ' + JSON.stringify(values)); value: {
await kvStore.putBatch(values).then(async (err) => { type: factory.ValueType.INTEGER,
value: '123'
}
}
entries.push(entry);
}
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 entries: ' + JSON.stringify(entries));
await kvStore.putBatch(entries).then(async (err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 putBatch success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 putBatch success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
var query = new factory.Query(); var query = new factory.Query();
query.prefixKey("name_"); query.prefixKey("key_test_");
await kvStore.getEntries(query).then((entrys) => { await kvStore.getEntries(query).then((entrys) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 getEntries success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 getEntries success');
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 entrys.length: ' + entrys.length); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 entrys.length: ' + entrys.length);
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 entrys[0]: ' + JSON.stringify(entrys[1])); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 entrys[0]: ' + JSON.stringify(entrys[0]));
expect(entrys.length == 2).assertTrue(); expect(entrys.length == 10).assertTrue();
done(); done();
}).catch((err) => { }).catch((err) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 delete fail ' + err); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 delete fail ' + err);
...@@ -1631,24 +1643,29 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1631,24 +1643,29 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300');
try { try {
let values = []; let entries = [];
let vb1 = {key : "name_1", value : 123}; for (var i = 0; i < 10; i++) {
let vb2 = {key : "name_2", value : 321.0}; var key = 'key_test_boolean';
let vb3 = {key : "name_3", value : 321.00}; var entry = {
values.push(vb1); key: key + i,
values.push(vb2); value: {
values.push(vb3); type: factory.ValueType.BOOLEAN,
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 values: ' + JSON.stringify(values)); value: 'true'
await kvStore.putBatch(values).then(async (err) => { }
}
entries.push(entry);
}
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 entries: ' + JSON.stringify(entries));
await kvStore.putBatch(entries).then(async (err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 putBatch success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 putBatch success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
var query = new factory.Query(); var query = new factory.Query();
query.prefixKey("name_"); query.prefixKey("key_test_");
await kvStore.getEntries(query).then((entrys) => { await kvStore.getEntries(query).then((entrys) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 getEntries success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 getEntries success');
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 entrys.length: ' + entrys.length); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 entrys.length: ' + entrys.length);
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 entrys[0]: ' + JSON.stringify(entrys[2])); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 entrys[0]: ' + JSON.stringify(entrys[0]));
expect(entrys.length == 3).assertTrue(); expect(entrys.length == 10).assertTrue();
done(); done();
}); });
}); });
...@@ -1668,22 +1685,29 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1668,22 +1685,29 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400');
try { try {
let values = []; let entries = [];
let vb1 = {key : "name_1", value : true}; for (var i = 0; i < 10; i++) {
let vb2 = {key : "name_2", value : false}; var key = 'key_test_float';
values.push(vb1); var entry = {
values.push(vb2); key: key + i,
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 values: ' + JSON.stringify(values)); value: {
await kvStore.putBatch(values).then(async (err) => { type: factory.ValueType.FLOAT,
value: '321.12'
}
}
entries.push(entry);
}
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 entries: ' + JSON.stringify(entries));
await kvStore.putBatch(entries).then(async (err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 putBatch success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 putBatch success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
var query = new factory.Query(); var query = new factory.Query();
query.prefixKey("name_"); query.prefixKey("key_test_");
await kvStore.getEntries(query).then((entrys) => { await kvStore.getEntries(query).then((entrys) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 getEntries success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 getEntries success');
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 entrys.length: ' + entrys.length); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 entrys.length: ' + entrys.length);
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 entrys[0]: ' + JSON.stringify(entrys[1])); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 entrys[0]: ' + JSON.stringify(entrys[0]));
expect(entrys.length == 2).assertTrue(); expect(entrys.length == 10).assertTrue();
done(); done();
}); });
}); });
...@@ -1703,23 +1727,32 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1703,23 +1727,32 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500');
try { try {
let values = []; let entries = [];
let vb1 = {key : "name_1", value : null}; for (var i = 0; i < 10; i++) {
let vb2 = {key : "name_2", value : null}; var key = 'key_test_string';
values.push(vb1); var entry = {
values.push(vb2); key: key + i,
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 values: ' + JSON.stringify(values)); value: {
await kvStore.putBatch(values).then(async (err) => { type: factory.ValueType.STRING,
value: 'value-string-001'
}
}
entries.push(entry);
}
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entries: ' + JSON.stringify(entries));
await kvStore.putBatch(entries).then(async (err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 putBatch success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 putBatch success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
var query = new factory.Query(); var query = new factory.Query();
query.prefixKey("name_"); query.prefixKey("key_test_");
await kvStore.getEntries(query).then((entrys) => { await kvStore.getEntries(query).then((entrys) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 getEntries success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 getEntries success');
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys.length: ' + entrys.length); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys.length: ' + entrys.length);
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys[0]: ' + JSON.stringify(entrys[1])); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys[1]: ' + JSON.stringify(entrys[1]));
expect(entrys.length == 2).assertTrue(); expect(entrys.length == 10).assertTrue();
expect(entrys[0].value == null).assertTrue(); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys[0]: ' + JSON.stringify(entrys[0]));
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys[0]: ' + JSON.stringify(entrys[0].value));
expect(entrys[0].value.value == 'value-string-001').assertTrue();
done(); done();
}); });
}); });
...@@ -1787,6 +1820,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1787,6 +1820,7 @@ describe('SingleKvStorePromiseTest', function () {
let keys = ['batch_test_string_key1', 'batch_test_string_key2']; let keys = ['batch_test_string_key1', 'batch_test_string_key2'];
await kvStore.deleteBatch(keys).then((err) => { await kvStore.deleteBatch(keys).then((err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0200 deleteBatch success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0200 deleteBatch success');
expect(err == undefined).assertTrue();
}).catch((err) => { }).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0200 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0200 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -1826,6 +1860,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1826,6 +1860,7 @@ describe('SingleKvStorePromiseTest', function () {
let keys = ['batch_test_string_key1', 'batch_test_string_keya']; let keys = ['batch_test_string_key1', 'batch_test_string_keya'];
await kvStore.deleteBatch(keys).then((err) => { await kvStore.deleteBatch(keys).then((err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0300 deleteBatch success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0300 deleteBatch success');
expect(err == undefined).assertTrue();
}).catch((err) => { }).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0300 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEBATCHVALUE_PROMISE_0300 deleteBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -1852,7 +1887,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1852,7 +1887,7 @@ describe('SingleKvStorePromiseTest', function () {
try { try {
var count = 0; var count = 0;
kvStore.on('dataChange', factory.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) { kvStore.on('dataChange', factory.SubscribeType.SUBSCRIBE_TYPE_ALL, function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 ' + JSON.stringify(data)); console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0100 dataChange ' + JSON.stringify(data));
count++; count++;
}); });
await kvStore.startTransaction().then(async (err) => { await kvStore.startTransaction().then(async (err) => {
...@@ -1906,7 +1941,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1906,7 +1941,7 @@ describe('SingleKvStorePromiseTest', function () {
try { try {
var count = 0; var count = 0;
kvStore.on('dataChange', 0, function (data) { kvStore.on('dataChange', 0, function (data) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 ' + JSON.stringify(data)); console.info('SUB_DDM_DKV_SINGLEKVSTORE_STARTTRANSACTION_PROMISE_0200 dataChange ' + JSON.stringify(data));
count++; count++;
}); });
await kvStore.startTransaction().then(async (err) => { await kvStore.startTransaction().then(async (err) => {
...@@ -2615,15 +2650,28 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2615,15 +2650,28 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0400', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0400', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0400'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0400');
try { try {
kvStore.getResultSet('test_key_string', 123).then((result) => { let resultSet;
await kvStore.getResultSet('test_key_string', 123).then((result) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0400 getResultSet success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0400 getResultSet success');
kvStore.closeResultSet(result); resultSet = result;
}) expect(resultSet.getCount() == 0).assertTrue();
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0400 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
});
await kvStore.closeResultSet(resultSet).then((err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0400 closeResultSet success');
expect(err == undefined).assertTrue();
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0400 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
});
}catch(e) { }catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
}) })
/** /**
...@@ -2762,9 +2810,9 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2762,9 +2810,9 @@ describe('SingleKvStorePromiseTest', function () {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0700 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0700 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail(); expect(null).assertFail();
}); });
let predicates = new dataShare.DataSharePredicates(); let query = new factory.Query();
predicates.prefixKey("name_"); query.prefixKey("name_");
await kvStore.getResultSet(predicates).then((result) => { await kvStore.getResultSet(query).then((result) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0700 getResultSet success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0700 getResultSet success');
resultSet = result; resultSet = result;
expect(resultSet.getCount() == 10).assertTrue(); expect(resultSet.getCount() == 10).assertTrue();
...@@ -2795,13 +2843,24 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2795,13 +2843,24 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800', 0, async function (done) {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800');
try { try {
let predicates = new dataShare.DataSharePredicates(); let resultSet;
await kvStore.getResultSet(predicates, async function (err, result) { let query = new factory.Query();
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800 GetResultSet success: '+`, error code is ${err.code}, message is ${err.message}`); await kvStore.getResultSet(query).then((result) => {
kvStore.closeResultSet(result); console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800 getResultSet success');
resultSet = result;
expect(resultSet.getCount() == 0).assertTrue();
}).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800 getResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
});
await kvStore.closeResultSet(resultSet).then((err) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800 closeResultSet success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
done(); }).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
}); });
} catch(e) { } catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800 e' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800 e' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -2873,7 +2932,6 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2873,7 +2932,6 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300');
try { try {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300 success');
let resultSet = null; let resultSet = null;
await kvStore.closeResultSet().then(() => { await kvStore.closeResultSet().then(() => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300 closeResultSet success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0300 closeResultSet success');
...@@ -2895,16 +2953,21 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2895,16 +2953,21 @@ describe('SingleKvStorePromiseTest', function () {
* @tc.name Test Js Api SingleKvStoreCloseResultSet testcase 004 * @tc.name Test Js Api SingleKvStoreCloseResultSet testcase 004
*/ */
it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400', 0, async function (done) {
let errorInfo = undefined; console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400');
try { try {
kvStore.closeResultSet("") let resultSet = null;
console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400 success'); await kvStore.closeResultSet("").then(() => {
}catch(err) { console.info('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400 closeResultSet success');
console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400 e ' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail();
errorInfo = err }).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400 closeResultSet fail ' + `, error code is ${err.code}, message is ${err.message}`);
});
}catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULTSET_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(e.code == 401).assertTrue();
} }
expect(errorInfo.code).assertEqual("401");
done(); done();
}) })
/** /**
...@@ -2968,9 +3031,11 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2968,9 +3031,11 @@ describe('SingleKvStorePromiseTest', function () {
}); });
await getInsertEntries.then(function(insertEntries){ await getInsertEntries.then(function(insertEntries){
console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100 getInsertEntries' + JSON.stringify(insertEntries)); console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100 getInsertEntries' + JSON.stringify(insertEntries));
expect(insertEntries).assertNotNull(); console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100 getInsertEntries key ' + insertEntries[0].key);
expect(insertEntries[0].key == "getInsertEntries").assertTrue();
}).catch((error) => { }).catch((error) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100 can NOT getInsertEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0100 can NOT getInsertEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`);
expect(null).assertFail();
}); });
done(); done();
}) })
...@@ -2995,9 +3060,11 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2995,9 +3060,11 @@ describe('SingleKvStorePromiseTest', function () {
}); });
await getUpdateEntries.then(function(updateEntries){ await getUpdateEntries.then(function(updateEntries){
console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0200 getUpdateEntries' + JSON.stringify(updateEntries)); console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0200 getUpdateEntries' + JSON.stringify(updateEntries));
expect(updateEntries).assertNotNull(); console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0200 getUpdateEntries key ' + updateEntries[0].key);
expect(updateEntries[0].key == "getUpdateEntries").assertTrue();
}).catch((error) => { }).catch((error) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0200 can NOT getUpdateEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0200 can NOT getUpdateEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`);
expect(null).assertFail();
}); });
done(); done();
}) })
...@@ -3021,10 +3088,12 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -3021,10 +3088,12 @@ describe('SingleKvStorePromiseTest', function () {
}); });
}); });
await getdeleteEntries.then(function(deleteEntries){ await getdeleteEntries.then(function(deleteEntries){
console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0300 deleteEntries' + JSON.stringify(getdeleteEntries)); console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0300 deleteEntries' + JSON.stringify(deleteEntries));
expect(deleteEntries != null).assertNotNull(); console.info('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0200 getUpdateEntries key ' + deleteEntries[0].key);
expect(deleteEntries[0].key == "deleteEntries").assertTrue();
}).catch((error) => { }).catch((error) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0300 can NOT getdeleteEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_CHANGENOTIFICATION_PROMISE_0300 can NOT getdeleteEntries, fail:' + `, error code is ${error.code}, message is ${error.message}`);
expect(null).assertFail();
}); });
done(); done();
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册