提交 7beb8a67 编写于 作者: W wuxiaodan

modify testcase

Signed-off-by: Nwuxiaodan <wuxiaodan5@huawei.com>
上级 49d22d2f
...@@ -30,18 +30,22 @@ describe('FieldNodeTest', function() { ...@@ -30,18 +30,22 @@ describe('FieldNodeTest', function() {
let child1 = new ddm.FieldNode("child1"); let child1 = new ddm.FieldNode("child1");
let child2 = new ddm.FieldNode("child2"); let child2 = new ddm.FieldNode("child2");
let child3 = new ddm.FieldNode("child3"); let child3 = new ddm.FieldNode("child3");
node.appendChild(child1); let res1 = node.appendChild(child1);
node.appendChild(child2); let res2 = node.appendChild(child2);
node.appendChild(child3); let res3 = node.appendChild(child3);
expect(res1).assertTrue();
expect(res2).assertTrue();
expect(res3).assertTrue();
child1 = null; child1 = null;
child2 = null; child2 = null;
child3 = null; child3 = null;
node = null; node = null;
done();
} catch (e) { } catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0100 " + e); console.info("SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0100 e=" + e);
expect(null).assertFail(); expect(null).assertFail();
done();
} }
done();
}) })
/** /**
...@@ -54,14 +58,16 @@ describe('FieldNodeTest', function() { ...@@ -54,14 +58,16 @@ describe('FieldNodeTest', function() {
try { try {
let node = new ddm.FieldNode("root"); let node = new ddm.FieldNode("root");
let child = new ddm.FieldNode("child"); let child = new ddm.FieldNode("child");
node.appendChild(child); let res1 = node.appendChild(child);
expect(res1).assertTrue();
child = null; child = null;
node = null; node = null;
done();
} catch (e) { } catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0200 " + e); console.info("SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0200 e=" + e);
expect(null).assertFail(); expect(null).assertFail();
done();
} }
done();
}) })
/** /**
...@@ -76,10 +82,11 @@ describe('FieldNodeTest', function() { ...@@ -76,10 +82,11 @@ describe('FieldNodeTest', function() {
let child = new ddm.FieldNode(); let child = new ddm.FieldNode();
node.appendChild(child); node.appendChild(child);
expect(null).assertFail(); expect(null).assertFail();
done();
} catch (e) { } catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0300 is ok :" + e); console.info("SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0300 is ok :" + e);
done();
} }
done();
}) })
/** /**
...@@ -92,11 +99,13 @@ describe('FieldNodeTest', function() { ...@@ -92,11 +99,13 @@ describe('FieldNodeTest', function() {
try { try {
let node = new ddm.FieldNode("root"); let node = new ddm.FieldNode("root");
let child = new ddm.FieldNode("child"); let child = new ddm.FieldNode("child");
node.appendChild(child); let res1 = node.appendChild(child);
expect(res1).assertTrue();
done();
} catch (e) { } catch (e) {
expect(null).assertFail(); expect(null).assertFail();
done();
} }
done();
}) })
/** /**
...@@ -109,11 +118,13 @@ describe('FieldNodeTest', function() { ...@@ -109,11 +118,13 @@ describe('FieldNodeTest', function() {
try { try {
let node = new ddm.FieldNode("root"); let node = new ddm.FieldNode("root");
let child = new ddm.FieldNode("child"); let child = new ddm.FieldNode("child");
node.appendChild(child); let res1 = node.appendChild(child);
expect(res1).assertTrue();
done();
} catch (e) { } catch (e) {
expect(null).assertFail(); expect(null).assertFail();
done();
} }
done();
}) })
/** /**
...@@ -128,10 +139,11 @@ describe('FieldNodeTest', function() { ...@@ -128,10 +139,11 @@ describe('FieldNodeTest', function() {
let child = new ddm.FieldNode(); let child = new ddm.FieldNode();
node.appendChild(child); node.appendChild(child);
expect(null).assertFail(); expect(null).assertFail();
done();
} catch (e) { } catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TOJSON_0300 is ok : " + e); console.info("SUB_DDM_DKV_FIELDNODE_TOJSON_0300 is ok : " + e);
done();
} }
done();
}) })
/** /**
...@@ -145,29 +157,33 @@ describe('FieldNodeTest', function() { ...@@ -145,29 +157,33 @@ describe('FieldNodeTest', function() {
let node = new ddm.FieldNode('first'); let node = new ddm.FieldNode('first');
node.default = 'first name'; node.default = 'first name';
console.info('defaultValue = ' + node.default); console.info('defaultValue = ' + node.default);
expect(node.default === 'first name').assertTrue() expect(node.default === 'first name').assertTrue();
done();
} catch (e) { } catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_DEFAULT_0100 fail on exception: " + e); console.info("SUB_DDM_DKV_FIELDNODE_DEFAULT_0100 fail on exception: " + e);
expect(null).assertFail();
done();
} }
done();
}) })
/** /**
* @tc.name SUB_DDM_DKV_FIELDNODE_DEFAULT_0100 * @tc.name SUB_DDM_DKV_FIELDNODE_NULLABLE_0100
* @tc.desc Test Js Api FieldNode.nullable testcase 001 * @tc.desc Test Js Api FieldNode.nullable testcase 001
* @tc.type: FUNC * @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_NULLABLE_0100 * @tc.number: SUB_DDM_DKV_FIELDNODE_NULLABLE_0100
*/ */
it('SUB_DDM_DKV_FIELDNODE_DEFAULT_0100', 0, async function(done) { it('SUB_DDM_DKV_FIELDNODE_NULLABLE_0100', 0, async function(done) {
try { try {
let node = new ddm.FieldNode('first'); let node = new ddm.FieldNode('first');
node.nullable = false; node.nullable = false;
console.info('nullable = ' + node.nullable); console.info('nullable = ' + node.nullable);
expect(node.nullable === false).assertTrue() expect(node.nullable === false).assertTrue();
done();
} catch (e) { } catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_DEFAULT_0100 fail on exception: " + e); console.info("SUB_DDM_DKV_FIELDNODE_NULLABLE_0100 fail on exception: " + e);
expect(null).assertFail();
done();
} }
done();
}) })
/** /**
...@@ -182,11 +198,12 @@ describe('FieldNodeTest', function() { ...@@ -182,11 +198,12 @@ describe('FieldNodeTest', function() {
node.type = ddm.ValueType.STRING; node.type = ddm.ValueType.STRING;
console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0100 type = ' + node.type); console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0100 type = ' + node.type);
expect(node.type === ddm.ValueType.STRING).assertTrue(); expect(node.type === ddm.ValueType.STRING).assertTrue();
done();
} catch (e) { } catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0100 fail on exception: " + e); console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0100 fail on exception: " + e);
expect(null).assertFail(); expect(null).assertFail();
done();
} }
done();
}) })
/** /**
...@@ -201,11 +218,12 @@ describe('FieldNodeTest', function() { ...@@ -201,11 +218,12 @@ describe('FieldNodeTest', function() {
node.type = ddm.ValueType.INTEGER; node.type = ddm.ValueType.INTEGER;
console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0200 type = ' + node.type); console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0200 type = ' + node.type);
expect(node.type === ddm.ValueType.INTEGER).assertTrue(); expect(node.type === ddm.ValueType.INTEGER).assertTrue();
done();
} catch (e) { } catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0200 fail on exception: " + e); console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0200 fail on exception: " + e);
expect(null).assertFail(); expect(null).assertFail();
done();
} }
done();
}) })
/** /**
...@@ -220,11 +238,12 @@ describe('FieldNodeTest', function() { ...@@ -220,11 +238,12 @@ describe('FieldNodeTest', function() {
node.type = ddm.ValueType.FLOAT; node.type = ddm.ValueType.FLOAT;
console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0300 type = ' + node.type); console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0300 type = ' + node.type);
expect(node.type === ddm.ValueType.FLOAT).assertTrue(); expect(node.type === ddm.ValueType.FLOAT).assertTrue();
done();
} catch (e) { } catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0300 fail on exception: " + e); console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0300 fail on exception: " + e);
expect(null).assertFail(); expect(null).assertFail();
done();
} }
done();
}) })
/** /**
...@@ -239,11 +258,12 @@ describe('FieldNodeTest', function() { ...@@ -239,11 +258,12 @@ describe('FieldNodeTest', function() {
node.type = ddm.ValueType.BYTE_ARRAY; node.type = ddm.ValueType.BYTE_ARRAY;
console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0400 type = ' + node.type); console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0400 type = ' + node.type);
expect(node.type === ddm.ValueType.BYTE_ARRAY).assertTrue(); expect(node.type === ddm.ValueType.BYTE_ARRAY).assertTrue();
done();
} catch (e) { } catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0400 fail on exception: " + e); console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0400 fail on exception: " + e);
expect(null).assertFail(); expect(null).assertFail();
done();
} }
done();
}) })
/** /**
...@@ -258,11 +278,12 @@ describe('FieldNodeTest', function() { ...@@ -258,11 +278,12 @@ describe('FieldNodeTest', function() {
node.type = ddm.ValueType.BOOLEAN; node.type = ddm.ValueType.BOOLEAN;
console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0500 type = ' + node.type); console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0500 type = ' + node.type);
expect(node.type === ddm.ValueType.BOOLEAN).assertTrue(); expect(node.type === ddm.ValueType.BOOLEAN).assertTrue();
done();
} catch (e) { } catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0500 fail on exception: " + e); console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0500 fail on exception: " + e);
expect(null).assertFail(); expect(null).assertFail();
done();
} }
done();
}) })
/** /**
...@@ -277,11 +298,12 @@ describe('FieldNodeTest', function() { ...@@ -277,11 +298,12 @@ describe('FieldNodeTest', function() {
node.type = ddm.ValueType.DOUBLE; node.type = ddm.ValueType.DOUBLE;
console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0600 type = ' + node.type); console.info('SUB_DDM_DKV_FIELDNODE_TYPE_0600 type = ' + node.type);
expect(node.type === ddm.ValueType.DOUBLE).assertTrue(); expect(node.type === ddm.ValueType.DOUBLE).assertTrue();
done();
} catch (e) { } catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0600 fail on exception: " + e); console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0600 fail on exception: " + e);
expect(null).assertFail(); expect(null).assertFail();
done();
} }
done();
}) })
}) })
} }
...@@ -73,7 +73,7 @@ describe('kvManagerCallbackTest', function () { ...@@ -73,7 +73,7 @@ describe('kvManagerCallbackTest', function () {
* @tc.number SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0100 * @tc.number SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0100
* @tc.desc Test Js Api KVManager.GetKVStore() testcase 001 * @tc.desc Test Js Api KVManager.GetKVStore() testcase 001
* @tc.type: FUNC * @tc.type: FUNC
* @tc.name Test Js Api KVManager.GetKVStore() testcase 00 * @tc.name Test Js Api KVManager.GetKVStore() testcase 001
*/ */
it('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0100', 0, async function (done) { it('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0100', 0, async function (done) {
console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0100'); console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0100');
...@@ -108,14 +108,16 @@ describe('kvManagerCallbackTest', function () { ...@@ -108,14 +108,16 @@ describe('kvManagerCallbackTest', function () {
if (err == undefined) { if (err == undefined) {
console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0200 getKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0200 getKVStore success');
expect(null).assertFail(); expect(null).assertFail();
done();
} else { } else {
expect((err.code == 401)).assertTrue(); console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0200 getKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
console.info('getKVStore fail' + `, error code is ${err.code}, message is ${err.message}`); expect(null).assertFail();
done();
} }
done();
}); });
} catch (e) { } catch (e) {
console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0200 getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0200 getKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(e.code == 401).assertTrue();
done(); done();
} }
}) })
...@@ -171,7 +173,7 @@ describe('kvManagerCallbackTest', function () { ...@@ -171,7 +173,7 @@ describe('kvManagerCallbackTest', function () {
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0400 getKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0400 getKVStore success');
expect(true).assertTrue(); expect((err == undefined) && (store != null)).assertTrue();
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -201,7 +203,7 @@ describe('kvManagerCallbackTest', function () { ...@@ -201,7 +203,7 @@ describe('kvManagerCallbackTest', function () {
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0500 getKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0500 getKVStore success');
expect(true).assertTrue(); expect((err == undefined) && (store != null)).assertTrue();
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -231,7 +233,7 @@ describe('kvManagerCallbackTest', function () { ...@@ -231,7 +233,7 @@ describe('kvManagerCallbackTest', function () {
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0600 getKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0600 getKVStore success');
expect(true).assertTrue(); expect((err == undefined) && (store != null)).assertTrue();
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -261,7 +263,7 @@ describe('kvManagerCallbackTest', function () { ...@@ -261,7 +263,7 @@ describe('kvManagerCallbackTest', function () {
try { try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0700 getKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_GETKVSTORE_0700 getKVStore success');
expect(true).assertTrue(); expect((err == undefined) && (store != null)).assertTrue();
done(); done();
}); });
} catch (e) { } catch (e) {
...@@ -282,6 +284,7 @@ describe('kvManagerCallbackTest', function () { ...@@ -282,6 +284,7 @@ describe('kvManagerCallbackTest', function () {
try { try {
await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0100 getKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0100 getKVStore success');
expect((err == undefined) && (store != null)).assertTrue();
kvStore = store; kvStore = store;
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore, function (err, data) { await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore, function (err, data) {
console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0100 closeKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0100 closeKVStore success');
...@@ -313,13 +316,16 @@ describe('kvManagerCallbackTest', function () { ...@@ -313,13 +316,16 @@ describe('kvManagerCallbackTest', function () {
if (err == undefined) { if (err == undefined) {
console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200 closeKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200 closeKVStore success');
expect(null).assertFail(); expect(null).assertFail();
done();
} else { } else {
console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200 closeKVStore fail'); console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200 closeKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
done();
} }
done();
}); });
} catch (e) { } catch (e) {
console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200 closeKVStore e ' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0200 closeKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(e.code == 401).assertTrue();
done(); done();
} }
}); });
...@@ -339,20 +345,23 @@ describe('kvManagerCallbackTest', function () { ...@@ -339,20 +345,23 @@ describe('kvManagerCallbackTest', function () {
it('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300', 0, async function (done) { it('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300', 0, async function (done) {
console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300'); console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300');
try { try {
await kvManager.getKVStore(TEST_STORE_ID, options, async function (err) { await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 getKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 getKVStore success');
try { try {
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, function (err) { await kvManager.closeKVStore(TEST_STORE_ID, function (err) {
if (err == undefined) { if (err == undefined) {
console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 closeKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 closeKVStore success');
expect(true).assertTrue(); expect(null).assertFail();
done();
} else { } else {
console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 closeKVStore fail'); console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 closeKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
done();
} }
done();
}); });
} catch (e) { } catch (e) {
console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 closeKVStore e ' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 closeKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(e.code == 401).assertTrue();
done(); done();
} }
}); });
...@@ -374,20 +383,24 @@ describe('kvManagerCallbackTest', function () { ...@@ -374,20 +383,24 @@ describe('kvManagerCallbackTest', function () {
try { try {
await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) { await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0400 getKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0400 getKVStore success');
kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, function (err, data) { kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, function (err, data) {
if (err != undefined) { if (err == undefined) {
console.info(`Fail to close KVStore.code is ${err.code},message is ${err.message}`); console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 closeKVStore success');
expect(err == undefined).assertTrue();
done();
} else {
console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0300 closeKVStore err ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
done();
} }
expect(err == undefined).assertTrue();
console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0400 closeKVStore1 done');
done();
console.info('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0400 closeKVStore redo.');
}) })
}); });
} catch (e) { } catch (e) {
console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0400 closeKVStore twice e ' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_KVMANAGER_CLOSEKVSTORE_0400 closeKVStore twice e ' + `, error code is ${e.code}, message is ${e.message}`);
// expect(null).assertFail(); expect(null).assertFail();
done();
} }
}) })
...@@ -408,13 +421,16 @@ describe('kvManagerCallbackTest', function () { ...@@ -408,13 +421,16 @@ describe('kvManagerCallbackTest', function () {
if (err == undefined) { if (err == undefined) {
console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100 deleteKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100 deleteKVStore success');
expect(null).assertFail(); expect(null).assertFail();
done();
} else { } else {
console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100 deleteKVStore fail'); console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100 deleteKVStore fail');
expect(null).assertFail();
done();
} }
done();
}); });
} catch (e) { } catch (e) {
console.error('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100 deleteKVStore e ' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0100 deleteKVStore e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(e.code == 401).assertTrue();
done(); done();
} }
}); });
...@@ -438,13 +454,16 @@ describe('kvManagerCallbackTest', function () { ...@@ -438,13 +454,16 @@ describe('kvManagerCallbackTest', function () {
if (err == undefined){ if (err == undefined){
console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0200 deleteKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0200 deleteKVStore success');
expect(null).assertFail(); expect(null).assertFail();
done();
} else { } else {
console.info('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0200 deleteKVStore fail'); console.error('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0200 err ' + `, error code is ${err.code}, message is ${err.message}`);
expect(err.code == 15100004).assertTrue();
done();
} }
done();
}); });
} catch (e) { } catch (e) {
console.error('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_KVMANAGER_DLETEKVSTORE_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail();
done(); done();
} }
}) })
...@@ -462,6 +481,7 @@ describe('kvManagerCallbackTest', function () { ...@@ -462,6 +481,7 @@ describe('kvManagerCallbackTest', function () {
console.info('SUB_DDM_DKV_KVMANAGER_GETALLKVSTOREID_0100 getAllKVStoreId success'); console.info('SUB_DDM_DKV_KVMANAGER_GETALLKVSTOREID_0100 getAllKVStoreId success');
console.info('SUB_DDM_DKV_KVMANAGER_GETALLKVSTOREID_0100 size = ' + data.length); console.info('SUB_DDM_DKV_KVMANAGER_GETALLKVSTOREID_0100 size = ' + data.length);
console.info('SUB_DDM_DKV_KVMANAGER_GETALLKVSTOREID_0100 err is: ' + err); console.info('SUB_DDM_DKV_KVMANAGER_GETALLKVSTOREID_0100 err is: ' + err);
expect(err == undefined).assertTrue();
expect(0).assertEqual(data.length); expect(0).assertEqual(data.length);
done(); done();
}); });
...@@ -485,17 +505,11 @@ describe('kvManagerCallbackTest', function () { ...@@ -485,17 +505,11 @@ describe('kvManagerCallbackTest', function () {
console.info('SUB_DDM_DKV_KVMANAGER_PUT_0100 getKVStore success'); console.info('SUB_DDM_DKV_KVMANAGER_PUT_0100 getKVStore success');
kvStore = store; kvStore = store;
await kvStore.put(STORE_KEY, STORE_VALUE, function (err, data) { await kvStore.put(STORE_KEY, STORE_VALUE, function (err, data) {
if (err != undefined){ console.info('SUB_DDM_DKV_KVMANAGER_PUT_0100 put callback success');
console.info('SUB_DDM_DKV_KVMANAGER_PUT_0100 put callback fail'); expect(err == undefined).assertTrue();
expect(null).assertFail();
} else {
console.info('SUB_DDM_DKV_KVMANAGER_PUT_0100 put callback success');
expect(true).assertTrue();
}
done(); done();
}); });
}); });
} catch (e) { } catch (e) {
console.error('SUB_DDM_DKV_KVMANAGER_PUT_0100 callback e ' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_KVMANAGER_PUT_0100 callback e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail(); expect(null).assertFail();
...@@ -503,6 +517,7 @@ describe('kvManagerCallbackTest', function () { ...@@ -503,6 +517,7 @@ describe('kvManagerCallbackTest', function () {
} }
}) })
/** /**
* @tc.number SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0100 * @tc.number SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0100
* @tc.desc Test Js Api createKVManager() testcase 001 * @tc.desc Test Js Api createKVManager() testcase 001
...@@ -510,19 +525,21 @@ describe('kvManagerCallbackTest', function () { ...@@ -510,19 +525,21 @@ describe('kvManagerCallbackTest', function () {
* @tc.name Test Js Api createKVManager() testcase 001 * @tc.name Test Js Api createKVManager() testcase 001
*/ */
it('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0100', 0, async function (done) { it('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0100', 0, async function (done) {
console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0100 start'); console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0100');
let kvManagerConfig = { const config = {
bundleName : [TEST_BUNDLE_NAME], bundleName: [TEST_BUNDLE_NAME],
context: context context:context
} }
try{ try {
factory.createKVManager(kvManagerConfig); kvManager = factory.createKVManager(config);
expect(false).assertTrue(); console.info('Create kvManager success');
}catch(err){ expect(null).assertFail();
console.info(`Create kvManager error: error code is ${err.code}, error message is ${err.message}`); done();
expect(err.code).assertEqual("401"); }catch (e) {
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0100 fail err' + `, error code is ${e.code}, message is ${e.message}`);
expect(e.code == 401).assertTrue();
done();
} }
done();
}) })
/** /**
...@@ -532,19 +549,22 @@ describe('kvManagerCallbackTest', function () { ...@@ -532,19 +549,22 @@ describe('kvManagerCallbackTest', function () {
* @tc.name Test Js Api createKVManager() testcase 002 * @tc.name Test Js Api createKVManager() testcase 002
*/ */
it('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0200', 0, async function (done) { it('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0200', 0, async function (done) {
console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0200 start '); console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0200');
let kvManagerConfig = { const config = {
bundleName : TEST_BUNDLE_NAME, bundleName: TEST_BUNDLE_NAME,
context: "context" context:"context"
} }
try{ try {
factory.createKVManager(kvManagerConfig); kvManager = factory.createKVManager(config);
expect(false).assertTrue(); console.info('Create kvManager success');
}catch(err){ expect(null).assertFail();
console.info(`Create kvManager error: error code is ${err.code}, error message is ${err.message}`); done();
expect(err.code).assertEqual("401"); }catch (e) {
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0200 fail err' + `, error code is ${e.code}, message is ${e.message}`);
expect(e.code == 401).assertTrue();
done();
} }
done();
}) })
/** /**
...@@ -555,14 +575,16 @@ describe('kvManagerCallbackTest', function () { ...@@ -555,14 +575,16 @@ describe('kvManagerCallbackTest', function () {
*/ */
it('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0300', 0, async function (done) { it('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0300', 0, async function (done) {
console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0300 start '); console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0300 start ');
try{ try {
factory.createKVManager("kvManagerConfig"); kvManager = factory.createKVManager("kvManagerConfig");
expect(false).assertTrue(); console.info('Create kvManager success');
}catch(err){ expect(null).assertFail();
console.info(`Create kvManager error: error code is ${err.code}, error message is ${err.message}`); done();
expect(err.code).assertEqual("401"); }catch (e) {
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0300 fail err' + `, error code is ${e.code}, message is ${e.message}`);
expect(e.code == 401).assertTrue();
done();
} }
done();
}) })
/** /**
...@@ -573,14 +595,16 @@ describe('kvManagerCallbackTest', function () { ...@@ -573,14 +595,16 @@ describe('kvManagerCallbackTest', function () {
*/ */
it('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0400', 0, async function (done) { it('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0400', 0, async function (done) {
console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0400 start '); console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0400 start ');
try{ try {
factory.createKVManager(); kvManager = factory.createKVManager();
expect(false).assertTrue(); console.info('Create kvManager success');
}catch(err){ expect(null).assertFail();
console.info(`Create kvManager error: error code is ${err.code}, error message is ${err.message}`); done();
expect(err.code).assertEqual("401"); }catch (e) {
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_0300 fail err' + `, error code is ${e.code}, message is ${e.message}`);
expect(e.code == 401).assertTrue();
done();
} }
done();
}) })
}) })
} }
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册