未验证 提交 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}`);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册