未验证 提交 8e0f3075 编写于 作者: O openharmony_ci 提交者: Gitee

!7052 【distributeddatamgr】【master】SingleKvStoreKVPromiseJsTest.js 用例优化

Merge pull request !7052 from wuxiaodan/master
...@@ -773,7 +773,7 @@ describe('SingleKvStoreCallbackTest', function () { ...@@ -773,7 +773,7 @@ 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 {
await kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) { await kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700 delete err: ' + err); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700 delete err: ' + err);
......
...@@ -773,14 +773,14 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -773,14 +773,14 @@ describe('SingleKvStorePromiseTest', function () {
try { try {
await kvStore.delete("KEY_TEST_STRING_ELEMENTS").then((data) => { await kvStore.delete("KEY_TEST_STRING_ELEMENTS").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(data == undefined).assertTrue();
}).catch((err) => { }).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 delete fail err ' + err); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 delete fail err ' + err);
expect(err == undefined).assertTrue(); expect(null).assertFail();
done();
}); });
}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();
}) })
...@@ -825,19 +825,22 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -825,19 +825,22 @@ describe('SingleKvStorePromiseTest', function () {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300');
try { try {
await kvStore.put("name", "Bob").then(async (data) => { await kvStore.put("number", "123").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) => { }).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 delete fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail(); expect(null).assertFail();
}); });
await kvStore.delete("name", function (err,data) { }).catch((err) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 delete success'); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(err != undefined).assertTrue(); expect(null).assertFail();
done();
}); });
}catch(e) { } catch (e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 e' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 put e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail(); expect(null).assertFail();
} }
done(); done();
...@@ -852,7 +855,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -852,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) => {
...@@ -878,7 +881,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -878,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) => {
...@@ -904,7 +907,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -904,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) => {
...@@ -946,6 +949,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -946,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}`);
...@@ -979,6 +983,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -979,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}`);
...@@ -1012,6 +1017,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1012,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}`);
...@@ -1030,7 +1036,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1030,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);
...@@ -1052,10 +1058,10 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1052,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);
...@@ -1077,10 +1083,10 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1077,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);
...@@ -1103,7 +1109,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1103,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');
...@@ -1124,7 +1130,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1124,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);
...@@ -1145,10 +1151,10 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1145,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);
...@@ -1170,10 +1176,10 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1170,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);
...@@ -1196,7 +1202,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1196,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');
...@@ -1222,7 +1228,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1222,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) {
...@@ -1247,7 +1253,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1247,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) {
...@@ -1272,7 +1278,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1272,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) {
...@@ -1568,7 +1574,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1568,7 +1574,7 @@ describe('SingleKvStorePromiseTest', function () {
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 == 10).assertTrue(); expect(entrys.length == 10).assertTrue();
done(); done();
}); });
...@@ -1610,7 +1616,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1610,7 +1616,7 @@ describe('SingleKvStorePromiseTest', function () {
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 == 10).assertTrue(); expect(entrys.length == 10).assertTrue();
done(); done();
}).catch((err) => { }).catch((err) => {
...@@ -1658,7 +1664,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1658,7 +1664,7 @@ describe('SingleKvStorePromiseTest', function () {
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 == 10).assertTrue(); expect(entrys.length == 10).assertTrue();
done(); done();
}); });
...@@ -1700,7 +1706,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1700,7 +1706,7 @@ describe('SingleKvStorePromiseTest', function () {
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 == 10).assertTrue(); expect(entrys.length == 10).assertTrue();
done(); done();
}); });
...@@ -1814,6 +1820,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1814,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();
...@@ -1853,6 +1860,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1853,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();
...@@ -1879,7 +1887,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1879,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) => {
...@@ -1933,7 +1941,7 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1933,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) => {
...@@ -2642,15 +2650,28 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2642,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();
}) })
/** /**
...@@ -2822,13 +2843,24 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2822,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 resultSet;
let query = new factory.Query(); let query = new factory.Query();
await kvStore.getResultSet(query, async function (err, result) { await kvStore.getResultSet(query).then((result) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800 GetResultSet success: '+`, error code is ${err.code}, message is ${err.message}`); console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800 getResultSet success');
kvStore.closeResultSet(result); 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();
...@@ -2900,7 +2932,6 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2900,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');
...@@ -2922,16 +2953,21 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2922,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();
}) })
/** /**
...@@ -2995,9 +3031,11 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2995,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();
}) })
...@@ -3022,9 +3060,11 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -3022,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();
}) })
...@@ -3048,10 +3088,12 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -3048,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.
先完成此消息的编辑!
想要评论请 注册