提交 fa5dc10a 编写于 作者: L liangzhenyu123

适配接口变更

Signed-off-by: Nliangzhenyu123 <liangzhenyu6@huawei.com>
上级 caaf5743
......@@ -76,12 +76,7 @@ describe('deviceKvStoreCallbackTest', function () {
beforeAll(async function (done) {
console.info('beforeAll config:'+ JSON.stringify(config));
await factory.createKVManager(config).then((manager) => {
kvManager = manager;
console.info('beforeAll createKVManager success');
}).catch((err) => {
console.error('beforeAll createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
});
kvManager = factory.createKVManager(config)
await kvManager.getKVStore(TEST_STORE_ID, options).then((store) => {
kvStore = store;
console.info('beforeAll getKVStore for getDeviceId success');
......
......@@ -76,12 +76,7 @@ describe('deviceKvStorePromiseTest', function () {
beforeAll(async function (done) {
console.info('beforeAll config:'+ JSON.stringify(config));
await factory.createKVManager(config).then((manager) => {
kvManager = manager;
console.info('beforeAll createKVManager success');
}).catch((err) => {
console.error('beforeAll createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
});
kvManager = factory.createKVManager(config);
await kvManager.getKVStore(TEST_STORE_ID, options).then((store) => {
kvStore = store;
console.info('beforeAll getKVStore for getDeviceId success');
......
......@@ -42,11 +42,9 @@ describe('kvManagerCallbackTest', function () {
beforeAll(async function (done) {
console.info('beforeAll');
await factory.createKVManager(config, function (err, manager) {
kvManager = manager;
done();
});
kvManager = factory.createKVManager(config);
console.info('beforeAll end');
done();
})
afterAll(async function (done) {
......
......@@ -45,17 +45,12 @@ describe('KVManagerPromiseTest', function () {
beforeAll(async function (done) {
console.info('beforeAll');
await factory.createKVManager(config).then((manager) => {
kvManager = manager;
console.info('beforeAll createKVManager success');
kvManager.getKVStore(TEST_STORE_ID, options).then((store) => {
console.info("beforeAll getKVStore success");
kvStoreNew = store;
}).catch((err) => {
console.info("beforeAll getKVStore err: " + JSON.stringify(err));
});
kvManager = factory.createKVManager(config)
kvManager.getKVStore(TEST_STORE_ID, options).then((store) => {
console.info("beforeAll getKVStore success");
kvStoreNew = store;
}).catch((err) => {
console.error('beforeAll createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
console.info("beforeAll getKVStore err: " + JSON.stringify(err));
});
console.info('beforeAll end');
done();
......@@ -394,36 +389,30 @@ describe('KVManagerPromiseTest', function () {
context:context
}
try {
await factory.createKVManager(config).then(async (manager) => {
kvManager = manager;
expect(manager !=null).assertTrue();
console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 createKVManager success');
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.info("testcreateKVManager001 getKVStore success");
await store.put(STORE_KEY, STORE_VALUE).then(async (data) => {
console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 put data success');
await store.get(STORE_KEY).then((data) => {
console.info("testcreateKVManager001 get data success");
expect(data).assertEqual(STORE_VALUE);
}).catch((err) => {
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 get data err' + `, error code is ${err.code}, message is ${err.message}`);
});
kvManager = factory.createKVManager(config)
kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.info("testcreateKVManager001 getKVStore success");
store.put(STORE_KEY, STORE_VALUE).then(async (data) => {
console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 put data success');
store.get(STORE_KEY).then((data) => {
console.info("testcreateKVManager001 get data success");
expect(data).assertEqual(STORE_VALUE);
done();
}).catch((err) => {
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 put data err' + `, error code is ${err.code}, message is ${err.message}`);
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 get data err' + `, error code is ${err.code}, message is ${err.message}`);
});
}).catch((err) => {
console.info("testcreateKVManager001 getKVStore err: " + JSON.stringify(err));
expect(null).assertFail();
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 put data err' + `, error code is ${err.code}, message is ${err.message}`);
});
}).catch((err) => {
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail()
console.info("testcreateKVManager001 getKVStore err: " + JSON.stringify(err));
expect(null).assertFail();
});
}catch (e) {
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 promise delete fail err' + `, error code is ${err.code}, message is ${err.message}`);
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0100 promise delete fail err' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail();
}
done();
})
/**
......@@ -439,35 +428,31 @@ describe('KVManagerPromiseTest', function () {
context:contextApplication
}
try {
await factory.createKVManager(config).then(async (manager) => {
kvManager = manager;
console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 createKVManager success');
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.info("testcreateKVManager002 getKVStore success");
await store.put(STORE_KEY, STORE_VALUE).then(async (data) => {
console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 put data success');
await store.get(STORE_KEY).then((data) => {
console.info("testcreateKVManager002 get data success");
expect(data).assertEqual(STORE_VALUE);
}).catch((err) => {
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 get data err' + `, error code is ${err.code}, message is ${err.message}`);
});
kvManager = factory.createKVManager(config)
kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.info("testcreateKVManager002 getKVStore success");
store.put(STORE_KEY, STORE_VALUE).then(async (data) => {
console.info('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 put data success');
store.get(STORE_KEY).then((data) => {
console.info("testcreateKVManager002 get data success");
expect(data).assertEqual(STORE_VALUE);
done();
}).catch((err) => {
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 put data err' + `, error code is ${err.code}, message is ${err.message}`);
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 get data err' + `, error code is ${err.code}, message is ${err.message}`);
});
}).catch((err) => {
console.info("testcreateKVManager002 getKVStore err: " + JSON.stringify(err));
expect(null).assertFail();
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 put data err' + `, error code is ${err.code}, message is ${err.message}`);
});
}).catch((err) => {
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail()
console.info("testcreateKVManager002 getKVStore err: " + JSON.stringify(err));
expect(null).assertFail();
});
}catch (e) {
console.error('SUB_DDM_DKV_KVMANAGER_CREATEKVMANAGER_PROMISE_0200 promise delete fail err' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail();
}
done();
})
})
}
\ No newline at end of file
......@@ -35,25 +35,16 @@ function sleep(ms) {
function publicgetKvStore(optionsp){
console.log(`Test getKvStore `)
return new Promise(function(resolve, reject) {
distributedData.createKVManager(mKVMgrConfig, (err, data) => {
console.info('Test createKVManager begin')
kvManager = distributedData.createKVManager(mKVMgrConfig);
kvManager.getKVStore(STORE_ID, optionsp, (err, data) => {
console.info('Test getKVStore begin')
if (err) {
console.info('Test createKVManager err = ' + err );
console.info('Test getKVStore err = ' + err);
reject(err);
}
console.info('Test createKVManager data = ' + data);
kvManager = data;
data.getKVStore(STORE_ID, optionsp, (err, data) => {
console.info('Test getKVStore begin')
if (err) {
console.info('Test getKVStore err = ' + err);
reject(err);
}
console.info('Test getKVStore data = ' + data);
kvStore = data;
resolve(data);
});
console.info('Test getKVStore data = ' + data);
kvStore = data;
resolve(data);
});
})
}
......
......@@ -32,25 +32,16 @@ let mKVMgrConfig = {
function publicgetKvStore(optionsp){
console.log(`Test getKvStore `)
return new Promise(function(resolve, reject) {
distributedData.createKVManager(mKVMgrConfig, (err, data) => {
console.info('Test createKVManager begin')
kvManager = distributedData.createKVManager(mKVMgrConfig);
kvManager.getKVStore(STORE_ID, optionsp, (err, data) => {
console.info('Test getKVStore begin')
if (err) {
console.info('Test createKVManager err = ' + err );
console.info('Test getKVStore err = ' + err);
reject(err);
}
console.info('Test createKVManager data = ' + data);
kvManager = data;
data.getKVStore(STORE_ID, optionsp, (err, data) => {
console.info('Test getKVStore begin')
if (err) {
console.info('Test getKVStore err = ' + err);
reject(err);
}
console.info('Test getKVStore data = ' + data);
kvStore = data;
resolve(data);
});
console.info('Test getKVStore data = ' + data);
kvStore = data;
resolve(data);
});
})
}
......
......@@ -42,12 +42,7 @@ export default function KvStoreResultSetTest(){
beforeAll(async function (done) {
console.info('beforeAll');
console.info('beforeAll config:' + JSON.stringify(config));
await factory.createKVManager(config).then((manager) => {
kvManager = manager;
console.info('beforeAll createKVManager success');
}).catch((err) => {
console.error('beforeAll createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
});
kvManager = factory.createKVManager(config);
await kvManager.getAllKVStoreId(TEST_BUNDLE_NAME).then(async (data) => {
console.info('beforeAll getAllKVStoreId size = ' + data.length);
for (var i = 0; i < data.length; i++) {
......
......@@ -104,18 +104,14 @@ describe('schemaTest', function() {
beforeAll(async function (done) {
try {
console.info("beforeAll: createKVManager (single) with " + JSON.stringify(options));
await ddm.createKVManager(config).then((manager) => {
kvManager = manager;
console.info('beforeAll createKVManager success');
}).catch((err) => {
console.info('beforeAll createKVManager err ' + err);
});
console.info("beforeAll: createKVManager (single) with " + JSON.stringify(config));
kvManager = ddm.createKVManager(config)
done();
} catch (e) {
console.info("fail on exception: " + e);
expect(null).assertFail();
}
done();
})
afterAll(async function (done) {
......
......@@ -75,11 +75,8 @@ describe('SingleKvStoreCallbackTest', function () {
beforeAll(async function (done) {
console.info('beforeAll config:'+ JSON.stringify(config));
await factory.createKVManager(config, function (err, manager) {
kvManager = manager;
console.info('beforeAll createKVManager success');
done();
})
kvManager = factory.createKVManager(config)
done();
})
afterAll(async function (done) {
......@@ -2337,6 +2334,7 @@ describe('SingleKvStoreCallbackTest', function () {
*/
it('SUB_DDM_DKV_SINGLEKVSTORE_CLOSERESULT_CALLBACK_8200', 0, async function (done) {
console.info('SingleKvStoreCloseResultSetCallbackTest004');
try{
kvStore.closeResultSet("",(err, data) => {
console.info('SingleKvStoreCloseResultSetCallbackTest004 close result finish')
......
......@@ -75,12 +75,7 @@ describe('SingleKvStorePromiseTest', function () {
beforeAll(async function (done) {
console.info('beforeAll config:'+ JSON.stringify(config));
await factory.createKVManager(config).then((manager) => {
kvManager = manager;
console.info('beforeAll createKVManager success');
}).catch((err) => {
console.error('beforeAll createKVManager err ' + `, error code is ${err.code}, message is ${err.message}`);
});
kvManager = factory.createKVManager(config)
console.info('beforeAll end');
done();
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册