提交 4601d0a3 编写于 作者: B bayanxing

分布式数据库用例修正

Signed-off-by: Nbayanxing <bayanxing@kaihongdigi.com>
上级 5e4739fb
......@@ -21,7 +21,6 @@ const STORE_KEY = 'key_test_string';
const STORE_VALUE = 'value-test-string';
var kvManager = null;
var kvStore = null;
var kvStoreNew = null;
describe('KVManagerCallbackTest', function () {
const config = {
......@@ -46,10 +45,7 @@ describe('KVManagerCallbackTest', function () {
console.log('beforeAll');
await factory.createKVManager(config, function (err, manager) {
kvManager = manager;
kvManager.getKVStore(TEST_STORE_ID, options, function (err, store) {
kvStoreNew = store;
done();
});
done();
});
console.log('beforeAll end');
})
......@@ -442,9 +438,10 @@ describe('KVManagerCallbackTest', function () {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
if (err == undefined) {
console.log('testKVManagerGetKVStore113 getKVStore success');
expect(null).assertFail();
expect((err == undefined) && (store != null)).assertTrue();
} else {
console.log('testKVManagerGetKVStore113 getKVStore fail');
expect(null).assertFail();
}
done();
});
......@@ -483,7 +480,7 @@ describe('KVManagerCallbackTest', function () {
done();
}
})
F
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_GETKVSTORE_1150
* @tc.name [JS-API8]KVManager.GetKVStore.
......@@ -503,13 +500,12 @@ describe('KVManagerCallbackTest', function () {
try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
console.log('testKVManagerGetKVStore115 getKVStore success');
expect((err == undefined) && (store != null)).assertTrue();
kvStore = store;
expect(null).assertFail();
done();
});
} catch (e) {
console.log('testKVManagerGetKVStore115 getKVStore e ' + e);
expect(null).assertFail();
expect(true).assertTrue();
done();
}
})
......@@ -533,13 +529,12 @@ describe('KVManagerCallbackTest', function () {
try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
console.log('testKVManagerGetKVStore116 getKVStore success');
expect((err == undefined) && (store != null)).assertTrue();
kvStore = store;
expect(null).assertFail();
done();
});
} catch (e) {
console.log('testKVManagerGetKVStore116 getKVStore e ' + e);
expect(null).assertFail();
expect(true).assertTrue();
done();
}
})
......@@ -563,13 +558,12 @@ describe('KVManagerCallbackTest', function () {
try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
console.log('testKVManagerGetKVStore117 getKVStore success');
expect((err == undefined) && (store != null)).assertTrue();
kvStore = store;
expect(null).assertFail();
done();
});
} catch (e) {
console.log('testKVManagerGetKVStore117 getKVStore e ' + e);
expect(null).assertFail();
expect(true).assertTrue();
done();
}
})
......@@ -593,13 +587,12 @@ describe('KVManagerCallbackTest', function () {
try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
console.log('testKVManagerGetKVStore118 getKVStore success');
expect((err == undefined) && (store != null)).assertTrue();
kvStore = store;
expect(null).assertFail();
done();
});
} catch (e) {
console.log('testKVManagerGetKVStore118 getKVStore e ' + e);
expect(null).assertFail();
expect(true).assertTrue();
done();
}
})
......@@ -623,13 +616,12 @@ describe('KVManagerCallbackTest', function () {
try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
console.log('testKVManagerGetKVStore119 getKVStore success');
expect((err == undefined) && (store != null)).assertTrue();
kvStore = store;
expect(null).assertFail();
done();
});
} catch (e) {
console.log('testKVManagerGetKVStore119 getKVStore e ' + e);
expect(null).assertFail();
expect(true).assertTrue();
done();
}
})
......@@ -653,13 +645,12 @@ describe('KVManagerCallbackTest', function () {
try {
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo, function (err, store) {
console.log('testKVManagerGetKVStore120 getKVStore success');
expect((err == undefined) && (store != null)).assertTrue();
kvStore = store;
expect(null).assertFail();
done();
});
} catch (e) {
console.log('testKVManagerGetKVStore119 getKVStore e ' + e);
expect(null).assertFail();
expect(true).assertTrue();
done();
}
})
......@@ -923,100 +914,34 @@ describe('KVManagerCallbackTest', function () {
it('testKVStorePut100', 0, async function (done) {
console.log('testKVStorePut100');
try {
await kvStoreNew.put(STORE_KEY, STORE_VALUE, function (err, data) {
if (err != undefined){
console.log('testKVStorePut100 put callback fail');
} else {
console.log('testKVStorePut100 put callback success');
expect(null).assertFail();
}
done();
});
} catch (e) {
console.log('testKVStorePut100 callback e ' + e);
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_DELETE_1000
* @tc.name [JS-API8]KVStore.Delete
* @tc.desc Test Js Api KVManager.Delete testcase 100
*/
it('testKVStoreDelete100', 0, async function (done) {
console.log('testKVStoreDelete100');
try {
await KVStoreNew.put(STORE_KEY, STORE_VALUE, async function (err,data) {
console.log('testKVStoreDelete100 put success');
try {
kvStore.delete(STORE_KEY, function (err, data) {
if (err == undefined) {
console.log('testKVStoreDelete100 callback delete success');
expect(null).assertFail();
await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
console.log('testKVStorePut100 getKVStore success');
kvStore = store;
await kvStore.put(STORE_KEY, STORE_VALUE, function (err, data) {
if (err != undefined){
console.log('testKVStorePut100 put callback fail');
} else {
console.log('testKVStoreDelete100 callback delete fail');
console.log('testKVStorePut100 put callback success');
expect(null).assertFail();
}
done();
});
} catch (e) {
console.log('testKVStoreDelete100 callback delete e ' + e);
done();
}
});
} catch (ee) {
console.log('testKVStoreDelete100 callback delete ee ' + ee);
expect(null).assertFail();
});
} catch (e) {
console.log('testKVStorePut100 callback e ' + e);
done();
}
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_ON_1000
* @tc.name [JS-API8]KVStore.On
* @tc.desc Test Js Api KVManager.On testcase 100
*/
it('testKVStoreOn100', 0, async function (done) {
kvStoreNew.on('dataChange', 0, function (data) {
console.log("testKVStoreOn100 callback call data: " + JSON.stringify(data));
expect(true).assertTrue();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_ON_1100
* @tc.name [JS-API8]KVStore.On
* @tc.desc Test Js Api KVManager.On testcase 101
*/
it('testKVStoreOn101', 0, async function (done) {
kvStoreNew.on('dataChange', 1, function (data) {
console.log("testKVStoreOn101 callback call data: " + JSON.stringify(data));
expect(true).assertTrue();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_ON_1200
* @tc.name [JS-API8]KVStore.On
* @tc.desc Test Js Api KVManager.On testcase 102
*/
it('testKVStoreOn102', 0, async function (done) {
kvStoreNew.on('dataChange', 2, function (data) {
console.log("testKVStoreOn102 callback call data: " + JSON.stringify(data));
expect(true).assertTrue();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVSTORE_ON_1300
* @tc.name [JS-API8]KVStore.On
* @tc.desc Test Js Api KVManager.On testcase 103
*/
it('testKVStoreOn103', 0, async function (done) {
kvStoreNew.on('syncComplete', function (data) {
console.log("testKVStoreOn103 callback call data: " + data);
console.log("testKVStoreOn101 callback call data: " + data);
expect(true).assertTrue();
});
done();
......
......@@ -441,11 +441,10 @@ describe('KVManagerPromiseTest', function () {
}
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore014 getKVStore success');
kvStore = store;
expect(store != null).assertTrue();
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerGetKVStore014 getKVStore err ' + err);
expect(null).assertFail();
expect(true).assertTrue();
});
done();
})
......@@ -468,11 +467,10 @@ describe('KVManagerPromiseTest', function () {
}
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore015 getKVStore success');
kvStore = store;
expect(store != null).assertTrue();
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerGetKVStore015 getKVStore err ' + err);
expect(null).assertFail();
expect(true).assertTrue();
});
done();
})
......@@ -495,11 +493,10 @@ describe('KVManagerPromiseTest', function () {
}
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore016 getKVStore success');
kvStore = store;
expect(store != null).assertTrue();
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerGetKVStore016 getKVStore err ' + err);
expect(null).assertFail();
expect(true).assertTrue();
});
done();
})
......@@ -522,11 +519,10 @@ describe('KVManagerPromiseTest', function () {
}
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore017 getKVStore success');
kvStore = store;
expect(store != null).assertTrue();
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerGetKVStore017 getKVStore err ' + err);
expect(null).assertFail();
expect(true).assertTrue();
});
done();
})
......@@ -549,11 +545,10 @@ describe('KVManagerPromiseTest', function () {
}
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore018 getKVStore success');
kvStore = store;
expect(store != null).assertTrue();
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerGetKVStore018 getKVStore err ' + err);
expect(null).assertFail();
expect(true).assertTrue();
});
done();
})
......@@ -576,11 +571,10 @@ describe('KVManagerPromiseTest', function () {
}
await kvManager.getKVStore(TEST_STORE_ID, optionsInfo).then((store) => {
console.log('testKVManagerGetKVStore019 getKVStore success');
kvStore = store;
expect(store != null).assertTrue();
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerGetKVStore019 getKVStore err ' + err);
expect(null).assertFail();
expect(true).assertTrue();
});
done();
})
......@@ -591,95 +585,18 @@ describe('KVManagerPromiseTest', function () {
* @tc.desc Test Js Api KVManager.CloseKVStore testcase 001
*/
it('testKVManagerCloseKVStore001', 0, async function (done) {
console.log('testKVManagerCloseKVStore001');
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.log('testKVManagerCloseKVStore001 getKVStore success');
kvStore = store;
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore).then(() => {
console.log('testKVManagerCloseKVStore001 closeKVStore success');
}).catch((err) => {
console.log('testKVManagerCloseKVStore001 closeKVStore err ' + err);
expect(null).assertFail();
});
}).catch((err) => {
console.log('testKVManagerCloseKVStore001 getKVStore err ' + err);
expect(null).assertFail();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_CLOSEKVSTORE_0200
* @tc.name [JS-API8]KVManager.CloseKVStore.
* @tc.desc Test Js Api KVManager.CloseKVStore testcase 002
*/
it('testKVManagerCloseKVStore002', 0, async function (done) {
console.log('testKVManagerCloseKVStore002');
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.log('testKVManagerCloseKVStore002 getKVStore success');
kvStore = store;
try {
await kvManager.closeKVStore(TEST_BUNDLE_NAME).then(() => {
console.log('testKVManagerCloseKVStore002 closeKVStore success');
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerCloseKVStore002 closeKVStore err ' + err);
});
} catch (e) {
console.log('testKVManagerCloseKVStore002 closeKVStore e ' + e);
}
}).catch((err) => {
console.log('testKVManagerCloseKVStore002 getKVStore err ' + err);
expect(null).assertFail();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_CLOSEKVSTORE_0300
* @tc.name [JS-API8]KVManager.CloseKVStore.
* @tc.desc Test Js Api KVManager.CloseKVStore testcase 003
*/
it('testKVManagerCloseKVStore003', 0, async function (done) {
console.log('testKVManagerCloseKVStore003');
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.log('testKVManagerCloseKVStore003 getKVStore success');
kvStore = store;
try {
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('testKVManagerCloseKVStore003 closeKVStore success');
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerCloseKVStore003 closeKVStore err ' + err);
});
} catch (e) {
console.log('testKVManagerCloseKVStore003 closeKVStore e ' + e);
}
}).catch((err) => {
console.log('testKVManagerCloseKVStore003 getKVStore err ' + err);
expect(null).assertFail();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_CLOSEKVSTORE_0400
* @tc.name [JS-API8]KVManager.CloseKVStore.
* @tc.desc Test Js Api KVManager.CloseKVStore testcase 004
*/
it('testKVManagerCloseKVStore004', 0, async function (done) {
console.log('testKVManagerCloseKVStore004');
await kvManager.getKVStore(TEST_STORE_ID, options, async function (err, store) {
console.log('testKVManagerCloseKVStore004 getKVStore success');
console.log('testKVManagerCloseKVStore001 getKVStore success');
kvStore = store;
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore);
});
console.log('testKVManagerCloseKVStore104 closeKVStore redo.');
console.log('testKVManagerCloseKVStore001 closeKVStore redo.');
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore).then(() => {
console.log('testKVManagerCloseKVStore004 closeKVStore twice');
console.log('testKVManagerCloseKVStore001 closeKVStore twice');
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerCloseKVStore004 closeKVStore twice err ' + err);
console.log('testKVManagerCloseKVStore001 closeKVStore twice err ' + err);
});
done();
})
......@@ -691,61 +608,11 @@ describe('KVManagerPromiseTest', function () {
*/
it('testKVManagerDeleteKVStore001', 0, async function (done) {
console.log('testKVManagerDeleteKVStore001');
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.log('testKVManagerDeleteKVStore001 getKVStore success');
kvStore = store;
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('testKVManagerDeleteKVStore001 deleteKVStore success');
}).catch((err) => {
console.log('testKVManagerDeleteKVStore001 deleteKVStore err ' + err);
expect(null).assertFail();
});
}).catch((err) => {
console.log('testKVManagerDeleteKVStore001 getKVStore err ' + err);
expect(null).assertFail();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_DELETEKVSTORE_0200
* @tc.name [JS-API8]KVManager.DeleteKVStore.
* @tc.desc Test Js Api KVManager.DeleteKVStore testcase 002
*/
it('testKVManagerDeleteKVStore002', 0, async function (done) {
console.log('testKVManagerDeleteKVStore002');
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.log('testKVManagerDeleteKVStore002 getKVStore success');
kvStore = store;
try {
await kvManager.deleteKVStore(TEST_BUNDLE_NAME).then(() => {
console.log('testKVManagerDeleteKVStore002 deleteKVStore success');
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerDeleteKVStore002 deleteKVStore err ' + err);
});
} catch (e) {
console.log('testKVManagerDeleteKVStore002 deleteKVStore e ' + e);
}
}).catch((err) => {
console.log('testKVManagerDeleteKVStore002 getKVStore err ' + err);
expect(null).assertFail();
});
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_KVMANAGER_DELETEKVSTORE_0300
* @tc.name [JS-API8]KVManager.DeleteKVStore.
* @tc.desc Test Js Api KVManager.DeleteKVStore testcase 003
*/
it('testKVManagerDeleteKVStore003', 0, async function (done) {
console.log('testKVManagerDeleteKVStore003');
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.log('testKVManagerDeleteKVStore003 deleteKVStore success');
console.log('testKVManagerDeleteKVStore001 deleteKVStore success');
expect(null).assertFail();
}).catch((err) => {
console.log('testKVManagerDeleteKVStore003 deleteKVStore err ' + err);
console.log('testKVManagerDeleteKVStore001 deleteKVStore err ' + err);
});
done();
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册