未验证 提交 4dc6173e 编写于 作者: O openharmony_ci 提交者: Gitee

!9927 【Distributeddatamgr】【Master】relationalStore用例优化,优化用例执行时序

Merge pull request !9927 from yanglifeng/master
...@@ -26,7 +26,7 @@ const STORE_CONFIG = { ...@@ -26,7 +26,7 @@ const STORE_CONFIG = {
var rdbStore = undefined; var rdbStore = undefined;
export default function rdbstoreTransactionTest() { export default function rdbstoreTransactionTest() {
describe('rdbstoreTransactionTest', function () { describe('rdbstoreTransactionTest', function () {
beforeAll(function () { beforeAll(function () {
console.info(TAG + 'beforeAll') console.info(TAG + 'beforeAll')
}) })
...@@ -75,7 +75,7 @@ describe('rdbstoreTransactionTest', function () { ...@@ -75,7 +75,7 @@ describe('rdbstoreTransactionTest', function () {
console.info(TAG + "testRdbTransactionInsert0001 result count " + resultSet.rowCount) console.info(TAG + "testRdbTransactionInsert0001 result count " + resultSet.rowCount)
expect(1).assertEqual(resultSet.rowCount) expect(1).assertEqual(resultSet.rowCount)
resultSet.close() resultSet.close()
// resultSet == null; // resultSet == null;
} catch (e) { } catch (e) {
console.info(TAG + e); console.info(TAG + e);
expect(null).assertFail() expect(null).assertFail()
...@@ -126,7 +126,7 @@ describe('rdbstoreTransactionTest', function () { ...@@ -126,7 +126,7 @@ describe('rdbstoreTransactionTest', function () {
let resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
expect(3).assertEqual(resultSet.rowCount) expect(3).assertEqual(resultSet.rowCount)
resultSet.close() resultSet.close()
// resultSet == null; // resultSet == null;
} catch (e) { } catch (e) {
expect(null).assertFail() expect(null).assertFail()
console.info(TAG + "testRdbTransactionInsert0002 failed"); console.info(TAG + "testRdbTransactionInsert0002 failed");
...@@ -167,7 +167,7 @@ describe('rdbstoreTransactionTest', function () { ...@@ -167,7 +167,7 @@ describe('rdbstoreTransactionTest', function () {
let resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
expect(0).assertEqual(resultSet.rowCount) expect(0).assertEqual(resultSet.rowCount)
resultSet.close() resultSet.close()
// resultSet == null; // resultSet == null;
const valueBucket2 = { const valueBucket2 = {
"name": "wangwu", "name": "wangwu",
"age": 16, "age": 16,
...@@ -214,7 +214,7 @@ describe('rdbstoreTransactionTest', function () { ...@@ -214,7 +214,7 @@ describe('rdbstoreTransactionTest', function () {
console.info(TAG + "testRdbTransactionRollBack0001 result count " + resultSet.rowCount); console.info(TAG + "testRdbTransactionRollBack0001 result count " + resultSet.rowCount);
expect(0).assertEqual(resultSet.rowCount) expect(0).assertEqual(resultSet.rowCount)
resultSet.close() resultSet.close()
// resultSet == null; // resultSet == null;
} }
done() done()
console.info(TAG + "************* testRdbTransactionRollBack0001 end *************"); console.info(TAG + "************* testRdbTransactionRollBack0001 end *************");
...@@ -247,8 +247,7 @@ describe('rdbstoreTransactionTest', function () { ...@@ -247,8 +247,7 @@ describe('rdbstoreTransactionTest', function () {
"salary": 220.5, "salary": 220.5,
"blobType": u8, "blobType": u8,
} }
let num = rdbStore.insert("test", valueBucket1) await rdbStore.insert("test", valueBucket1).then(async (ret) => {
num.then(async (ret) => {
console.info(TAG + "testRdbTransactionMulti0001 * insert result " + ret); console.info(TAG + "testRdbTransactionMulti0001 * insert result " + ret);
expect(2).assertEqual(ret) expect(2).assertEqual(ret)
}) })
...@@ -257,16 +256,15 @@ describe('rdbstoreTransactionTest', function () { ...@@ -257,16 +256,15 @@ describe('rdbstoreTransactionTest', function () {
await rdbStore.commit() await rdbStore.commit()
let predicates = new dataRdb.RdbPredicates("test"); let predicates = new dataRdb.RdbPredicates("test");
num = rdbStore.query(predicates) await rdbStore.query(predicates).then(async (ret) => {
num.then(async (ret) => {
expect(2).assertEqual(ret.rowCount) expect(2).assertEqual(ret.rowCount)
done()
console.info(TAG + "************* testRdbTransactionMulti0001 end *************");
ret.close() ret.close()
}) })
} catch (e) { } catch (e) {
console.info(TAG + "testRdbTransactionMulti0001 fail ***** "); console.info(TAG + "testRdbTransactionMulti0001 fail ***** ");
} }
done()
console.info(TAG + "************* testRdbTransactionMulti0001 end *************");
}) })
/** /**
...@@ -287,9 +285,7 @@ describe('rdbstoreTransactionTest', function () { ...@@ -287,9 +285,7 @@ describe('rdbstoreTransactionTest', function () {
"salary": 100.5, "salary": 100.5,
"blobType": u8, "blobType": u8,
} }
await rdbStore.insert("test", valueBucket, function (err, ret){ await rdbStore.insert("test", valueBucket);
});
await rdbStore.beginTransaction() await rdbStore.beginTransaction()
const valueBucket1 = { const valueBucket1 = {
...@@ -298,29 +294,29 @@ describe('rdbstoreTransactionTest', function () { ...@@ -298,29 +294,29 @@ describe('rdbstoreTransactionTest', function () {
"salary": 220.5, "salary": 220.5,
"blobType": u8, "blobType": u8,
} }
let num = rdbStore.insert("test", valueBucket1) await rdbStore.insert("test", valueBucket1, async function (err, ret1){
num.then(async (ret) => { console.info(TAG + "testRdbTransactionMulti0002 * insert result " + ret1);
console.info(TAG + "testRdbTransactionMulti0002 * insert result " + ret); expect(2).assertEqual(ret1)
expect(2).assertEqual(ret)
ret.close()
})
await rdbStore.rollBack() await rdbStore.rollBack()
await rdbStore.commit() await rdbStore.commit()
let predicates = new dataRdb.RdbPredicates("test"); let predicates = new dataRdb.RdbPredicates("test");
num = rdbStore.query(predicates) await rdbStore.query(predicates).then(async (ret2) => {
num.then(async (ret) => { console.info(TAG + "testRdbTransactionMulti0002 * final query " + ret2.rowCount);
console.info(TAG + "testRdbTransactionMulti0002 * final query " + ret.rowCount); expect(1).assertEqual(ret2.rowCount)
expect(1).assertEqual(ret.rowCount) done()
ret.close() console.info(TAG + "************* testRdbTransactionMulti0002 end *************");
ret2.close()
})
}) })
} catch (e) { } catch (e) {
console.info(TAG + "testRdbTransactionMulti0002 fail ***** "); console.info(TAG + "testRdbTransactionMulti0002 fail ***** ");
expect().assertFail();
done();
} }
done()
console.info(TAG + "************* testRdbTransactionMulti0002 end *************");
}) })
/** /**
...@@ -341,37 +337,41 @@ describe('rdbstoreTransactionTest', function () { ...@@ -341,37 +337,41 @@ describe('rdbstoreTransactionTest', function () {
"salary": 100.5, "salary": 100.5,
"blobType": u8, "blobType": u8,
} }
await rdbStore.insert("test", valueBucket, function (err, ret){ await rdbStore.insert("test", valueBucket);
}); await rdbStore.beginTransaction();
const valueBucket2 = {
await rdbStore.beginTransaction()
const valueBucket1 = {
"name": "zhangsan", "name": "zhangsan",
"age": 20, "age": 20,
"salary": 220.5, "salary": 220.5,
"blobType": u8, "blobType": u8,
} }
let num = await rdbStore.insert("test", valueBucket1) await rdbStore.insert("test", valueBucket2);
await rdbStore.rollBack() await rdbStore.rollBack();
await rdbStore.insert("test", valueBucket) const valueBucket3 = {
await rdbStore.commit() "name": "wangwu",
"age": 18,
"salary": 100.5,
"blobType": u8,
}
await rdbStore.insert("test", valueBucket3);
await rdbStore.commit();
let predicates = new dataRdb.RdbPredicates("test"); let predicates = new dataRdb.RdbPredicates("test");
num = rdbStore.query(predicates) await rdbStore.query(predicates).then(async (ret) => {
num.then(async (ret) => {
console.info(TAG + "testRdbTransactionMulti0003 * final query " + ret.rowCount); console.info(TAG + "testRdbTransactionMulti0003 * final query " + ret.rowCount);
expect(1).assertEqual(ret.rowCount) expect(2).assertEqual(ret.rowCount);
ret.close() done();
console.info(TAG + "************* testRdbTransactionMulti0003 end *************");
ret.close();
}) })
} catch (e) { } catch (e) {
await rdbStore.rollBack() await rdbStore.rollBack()
console.info(TAG + "testRdbTransactionMulti0003 rollback ***** "); console.info(TAG + "testRdbTransactionMulti0003 rollback ***** ");
} }
done()
console.info(TAG + "************* testRdbTransactionMulti0003 end *************");
}) })
/** /**
...@@ -405,7 +405,7 @@ describe('rdbstoreTransactionTest', function () { ...@@ -405,7 +405,7 @@ describe('rdbstoreTransactionTest', function () {
let resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
expect(0).assertEqual(resultSet.rowCount) expect(0).assertEqual(resultSet.rowCount)
resultSet.close() resultSet.close()
// resultSet == null; // resultSet == null;
const valueBucket2 = { const valueBucket2 = {
"name": "wangwu", "name": "wangwu",
"age": 16, "age": 16,
...@@ -422,18 +422,18 @@ describe('rdbstoreTransactionTest', function () { ...@@ -422,18 +422,18 @@ describe('rdbstoreTransactionTest', function () {
//删除 //删除
{ {
let predicates = await new dataRdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
let deletePromise = rdbStore.delete(predicates) await rdbStore.delete(predicates).then(async (ret) => {
deletePromise.then(async (ret) => { expect(3).assertEqual(ret);
expect(3).assertEqual(ret) done()
console.info(TAG + "************* testRdbTransactionDelete0001 end *************");
console.info(TAG + "Delete done: " + ret) console.info(TAG + "Delete done: " + ret)
}).catch((err) => { }).catch((err) => {
expect(null).assertFail() expect(null).assertFail();
done();
}) })
await deletePromise
} }
done()
console.info(TAG + "************* testRdbTransactionDelete0001 end *************");
}) })
console.info(TAG + "*************Unit Test End*************"); console.info(TAG + "*************Unit Test End*************");
})} })}
...@@ -23,7 +23,7 @@ const STORE_CONFIG = { ...@@ -23,7 +23,7 @@ const STORE_CONFIG = {
var rdbStore = undefined; var rdbStore = undefined;
export default function rdbStoreUpdateTest() { export default function rdbStoreUpdateTest() {
describe('rdbStoreUpdateTest', function () { describe('rdbStoreUpdateTest', function () {
beforeAll(function () { beforeAll(function () {
console.info(TAG + 'beforeAll') console.info(TAG + 'beforeAll')
}) })
...@@ -234,27 +234,25 @@ describe('rdbStoreUpdateTest', function () { ...@@ -234,27 +234,25 @@ describe('rdbStoreUpdateTest', function () {
{ {
let predicates = await new dataRdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
await predicates.equalTo("aaa", "null") await predicates.equalTo("aaa", "null")
let updatePromise = rdbStore.update(valueBucket, predicates) await rdbStore.update(valueBucket, predicates).then(async (ret) => {
updatePromise.then(async (ret) => {
console.info(TAG + "update done: " + ret); console.info(TAG + "update done: " + ret);
expect(null).assertFail(); expect(null).assertFail();
}).catch((err) => { }).catch((err) => {
console.info(TAG + "update with wrong condition"); console.info(TAG + "update with wrong condition");
expect(err !== null).assertTrue();
}) })
//await updatePromise
} }
{ {
const emptyBucket = {};
let predicates = await new dataRdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
await predicates.equalTo("name", "zhangsan") await predicates.equalTo("name", "zhangsan")
await predicates.equalTo("age", 18) await predicates.equalTo("age", 18)
await predicates.equalTo("null", 100.5) await predicates.equalTo("null", 100.5)
let updatePromise = rdbStore.update(valueBucket, predicates) await rdbStore.update(valueBucket, predicates).then(async (ret) => {
updatePromise.then(async (ret) => {
console.info(TAG + "update done: " + ret); console.info(TAG + "update done: " + ret);
expect(null).assertFail(); expect(ret).assertEqual(0);
}).catch((err) => { }).catch((err) => {
console.info(TAG + "update with wrong condition"); console.info(TAG + "update with wrong condition");
expect(null).assertFail();
}) })
} }
} }
...@@ -262,6 +260,6 @@ describe('rdbStoreUpdateTest', function () { ...@@ -262,6 +260,6 @@ describe('rdbStoreUpdateTest', function () {
console.info(TAG + "************* testRdbStoreUpdate0004 end *************"); console.info(TAG + "************* testRdbStoreUpdate0004 end *************");
}) })
console.info(TAG + "*************Unit Test End*************"); console.info(TAG + "*************Unit Test End*************");
}) })
} }
...@@ -501,7 +501,7 @@ export default function relationalStoreAssetResultSetTest() { ...@@ -501,7 +501,7 @@ export default function relationalStoreAssetResultSetTest() {
done(); done();
} catch (e) { } catch (e) {
console.log(TAG + "testGetAssetUndefined get error" + JSON.stringify(e)); console.log(TAG + "testGetAssetUndefined get error" + JSON.stringify(e));
expect(14800000).assertEqual(e.code) expect('401').assertEqual(e.code)
done(); done();
} }
}) })
...@@ -531,7 +531,7 @@ export default function relationalStoreAssetResultSetTest() { ...@@ -531,7 +531,7 @@ export default function relationalStoreAssetResultSetTest() {
done(); done();
} catch (e) { } catch (e) {
console.log(TAG + "testGetAssetNull get error" + JSON.stringify(e)); console.log(TAG + "testGetAssetNull get error" + JSON.stringify(e));
expect(14800000).assertEqual(e.code) expect('401').assertEqual(e.code)
done(); done();
} }
}) })
......
...@@ -29,7 +29,7 @@ const STORE_CONFIG = { ...@@ -29,7 +29,7 @@ const STORE_CONFIG = {
var rdbStore = undefined; var rdbStore = undefined;
export default function relationalStoreTransactionTest() { export default function relationalStoreTransactionTest() {
describe('relationalStoreTransactionTest', function () { describe('relationalStoreTransactionTest', function () {
beforeAll(function () { beforeAll(function () {
console.info(TAG + 'beforeAll') console.info(TAG + 'beforeAll')
}) })
...@@ -78,7 +78,7 @@ describe('relationalStoreTransactionTest', function () { ...@@ -78,7 +78,7 @@ describe('relationalStoreTransactionTest', function () {
console.info(TAG + "testRdbTransactionInsert0001 result count " + resultSet.rowCount) console.info(TAG + "testRdbTransactionInsert0001 result count " + resultSet.rowCount)
expect(1).assertEqual(resultSet.rowCount) expect(1).assertEqual(resultSet.rowCount)
resultSet.close() resultSet.close()
// resultSet == null; // resultSet == null;
} catch (e) { } catch (e) {
console.info(TAG + e); console.info(TAG + e);
expect(null).assertFail() expect(null).assertFail()
...@@ -129,7 +129,7 @@ describe('relationalStoreTransactionTest', function () { ...@@ -129,7 +129,7 @@ describe('relationalStoreTransactionTest', function () {
let resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
expect(3).assertEqual(resultSet.rowCount) expect(3).assertEqual(resultSet.rowCount)
resultSet.close() resultSet.close()
// resultSet == null; // resultSet == null;
} catch (e) { } catch (e) {
expect(null).assertFail() expect(null).assertFail()
console.info(TAG + "testRdbTransactionInsert0002 failed"); console.info(TAG + "testRdbTransactionInsert0002 failed");
...@@ -170,7 +170,7 @@ describe('relationalStoreTransactionTest', function () { ...@@ -170,7 +170,7 @@ describe('relationalStoreTransactionTest', function () {
let resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
expect(0).assertEqual(resultSet.rowCount) expect(0).assertEqual(resultSet.rowCount)
resultSet.close() resultSet.close()
// resultSet == null; // resultSet == null;
const valueBucket2 = { const valueBucket2 = {
"name": "wangwu", "name": "wangwu",
"age": 16, "age": 16,
...@@ -217,7 +217,7 @@ describe('relationalStoreTransactionTest', function () { ...@@ -217,7 +217,7 @@ describe('relationalStoreTransactionTest', function () {
console.info(TAG + "testRdbTransactionRollBack0001 result count " + resultSet.rowCount); console.info(TAG + "testRdbTransactionRollBack0001 result count " + resultSet.rowCount);
expect(0).assertEqual(resultSet.rowCount) expect(0).assertEqual(resultSet.rowCount)
resultSet.close() resultSet.close()
// resultSet == null; // resultSet == null;
} }
done() done()
console.info(TAG + "************* testRdbTransactionRollBack0001 end *************"); console.info(TAG + "************* testRdbTransactionRollBack0001 end *************");
...@@ -230,7 +230,7 @@ describe('relationalStoreTransactionTest', function () { ...@@ -230,7 +230,7 @@ describe('relationalStoreTransactionTest', function () {
* db returns an exception, we need to catch exception and rollback. * db returns an exception, we need to catch exception and rollback.
*/ */
it('testRdbTransactionMulti0001', 0, async function (done) { it('testRdbTransactionMulti0001', 0, async function (done) {
console.info(TAG + "************* testRdbTransactionMulti0001 start *************"); console.info('ttt' + "************* testRdbTransactionMulti0001 start *************");
var u8 = new Uint8Array([1, 2, 3]) var u8 = new Uint8Array([1, 2, 3])
try { try {
await rdbStore.beginTransaction() await rdbStore.beginTransaction()
...@@ -251,25 +251,25 @@ describe('relationalStoreTransactionTest', function () { ...@@ -251,25 +251,25 @@ describe('relationalStoreTransactionTest', function () {
"blobType": u8, "blobType": u8,
} }
let num = rdbStore.insert("test", valueBucket1) let num = rdbStore.insert("test", valueBucket1)
num.then(async (ret) => { num.then(async (ret1) => {
console.info(TAG + "testRdbTransactionMulti0001 * insert result " + ret); console.info('ttt' + "testRdbTransactionMulti0001 * insert result " + ret1);
expect(2).assertEqual(ret) expect(2).assertEqual(ret1)
}) })
await rdbStore.commit() await rdbStore.commit()
await rdbStore.commit() await rdbStore.commit()
let predicates = new data_Rdb.RdbPredicates("test"); let predicates = new data_Rdb.RdbPredicates("test");
num = rdbStore.query(predicates) await rdbStore.query(predicates).then(async (ret2) => {
num.then(async (ret) => { console.info('ttt' + "testRdbTransactionMulti0001 ret.rowCount = " + ret2.rowCount);
expect(2).assertEqual(ret.rowCount) expect(2).assertEqual(ret2.rowCount)
ret.close() done()
console.info('ttt' + "************* testRdbTransactionMulti0001 end *************");
ret2.close()
}) })
} catch (e) { } catch (e) {
console.info(TAG + "testRdbTransactionMulti0001 fail ***** "); console.info('ttt' + "testRdbTransactionMulti0001 fail ***** ");
} }
done()
console.info(TAG + "************* testRdbTransactionMulti0001 end *************");
}) })
/** /**
...@@ -280,7 +280,7 @@ describe('relationalStoreTransactionTest', function () { ...@@ -280,7 +280,7 @@ describe('relationalStoreTransactionTest', function () {
*/ */
it('testRdbTransactionMulti0002', 0, async function (done) { it('testRdbTransactionMulti0002', 0, async function (done) {
console.info(TAG + "************* testRdbTransactionMulti0002 start *************"); console.info(TAG + "************* testRdbTransactionMulti0002 start *************");
var u8 = new Uint8Array([1, 2, 3]) let u8 = new Uint8Array([1, 2, 3])
try { try {
await rdbStore.beginTransaction() await rdbStore.beginTransaction()
const valueBucket = { const valueBucket = {
...@@ -290,9 +290,7 @@ describe('relationalStoreTransactionTest', function () { ...@@ -290,9 +290,7 @@ describe('relationalStoreTransactionTest', function () {
"salary": 100.5, "salary": 100.5,
"blobType": u8, "blobType": u8,
} }
await rdbStore.insert("test", valueBucket, function (err, ret){ await rdbStore.insert("test", valueBucket)
});
await rdbStore.beginTransaction() await rdbStore.beginTransaction()
const valueBucket1 = { const valueBucket1 = {
...@@ -301,31 +299,30 @@ describe('relationalStoreTransactionTest', function () { ...@@ -301,31 +299,30 @@ describe('relationalStoreTransactionTest', function () {
"salary": 220.5, "salary": 220.5,
"blobType": u8, "blobType": u8,
} }
let num = rdbStore.insert("test", valueBucket1) await rdbStore.insert("test", valueBucket1, async function (err, ret1){
num.then(async (ret) => { console.info(TAG + "testRdbTransactionMulti0002 * insert result " + ret1);
console.info(TAG + "testRdbTransactionMulti0002 * insert result " + ret); expect(2).assertEqual(ret1);
expect(2).assertEqual(ret)
ret.close()
})
await rdbStore.rollBack() await rdbStore.rollBack()
await rdbStore.commit() await rdbStore.commit()
let predicates = new data_Rdb.RdbPredicates("test"); let predicates = new data_Rdb.RdbPredicates("test");
num = rdbStore.query(predicates) await rdbStore.query(predicates).then(async (ret2) => {
num.then(async (ret) => { console.info(TAG + "testRdbTransactionMulti0002 * final query " + ret2.rowCount);
console.info(TAG + "testRdbTransactionMulti0002 * final query " + ret.rowCount); expect(1).assertEqual(ret2.rowCount)
expect(1).assertEqual(ret.rowCount) done()
ret.close() console.info(TAG + "************* testRdbTransactionMulti0002 end *************");
ret2.close()
}) })
})
} catch (e) { } catch (e) {
console.info(TAG + "testRdbTransactionMulti0002 fail ***** "); console.info(TAG + "testRdbTransactionMulti0002 fail ***** ");
expect().assertFail();
done();
} }
done()
console.info(TAG + "************* testRdbTransactionMulti0002 end *************");
}) })
/** /**
* @tc.name RelationalStore insert test * @tc.name RelationalStore insert test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Multi_0003 * @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Multi_0003
...@@ -344,37 +341,41 @@ describe('relationalStoreTransactionTest', function () { ...@@ -344,37 +341,41 @@ describe('relationalStoreTransactionTest', function () {
"salary": 100.5, "salary": 100.5,
"blobType": u8, "blobType": u8,
} }
await rdbStore.insert("test", valueBucket, function (err, ret){ await rdbStore.insert("test", valueBucket);
}); await rdbStore.beginTransaction();
const valueBucket2 = {
await rdbStore.beginTransaction()
const valueBucket1 = {
"name": "zhangsan", "name": "zhangsan",
"age": 20, "age": 20,
"salary": 220.5, "salary": 220.5,
"blobType": u8, "blobType": u8,
} }
let num = await rdbStore.insert("test", valueBucket1) await rdbStore.insert("test", valueBucket2);
await rdbStore.rollBack() await rdbStore.rollBack();
await rdbStore.insert("test", valueBucket) const valueBucket3 = {
await rdbStore.commit() "name": "wangwu",
"age": 18,
"salary": 100.5,
"blobType": u8,
}
await rdbStore.insert("test", valueBucket3);
await rdbStore.commit();
let predicates = new data_Rdb.RdbPredicates("test"); let predicates = new data_Rdb.RdbPredicates("test");
num = rdbStore.query(predicates) await rdbStore.query(predicates).then(async (ret) => {
num.then(async (ret) => {
console.info(TAG + "testRdbTransactionMulti0003 * final query " + ret.rowCount); console.info(TAG + "testRdbTransactionMulti0003 * final query " + ret.rowCount);
expect(1).assertEqual(ret.rowCount) expect(2).assertEqual(ret.rowCount);
ret.close() done();
console.info(TAG + "************* testRdbTransactionMulti0003 end *************");
ret.close();
}) })
} catch (e) { } catch (e) {
await rdbStore.rollBack() await rdbStore.rollBack()
console.info(TAG + "testRdbTransactionMulti0003 rollback ***** "); console.info(TAG + "testRdbTransactionMulti0003 rollback ***** ");
} }
done()
console.info(TAG + "************* testRdbTransactionMulti0003 end *************");
}) })
/** /**
...@@ -408,7 +409,7 @@ describe('relationalStoreTransactionTest', function () { ...@@ -408,7 +409,7 @@ describe('relationalStoreTransactionTest', function () {
let resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
expect(0).assertEqual(resultSet.rowCount) expect(0).assertEqual(resultSet.rowCount)
resultSet.close() resultSet.close()
// resultSet == null; // resultSet == null;
const valueBucket2 = { const valueBucket2 = {
"name": "wangwu", "name": "wangwu",
"age": 16, "age": 16,
...@@ -425,18 +426,18 @@ describe('relationalStoreTransactionTest', function () { ...@@ -425,18 +426,18 @@ describe('relationalStoreTransactionTest', function () {
//删除 //删除
{ {
let predicates = await new data_Rdb.RdbPredicates("test") let predicates = await new data_Rdb.RdbPredicates("test")
let deletePromise = rdbStore.delete(predicates) await rdbStore.delete(predicates).then(async (ret) => {
deletePromise.then(async (ret) => { expect(3).assertEqual(ret);
expect(3).assertEqual(ret) done()
console.info(TAG + "************* testRdbTransactionDelete0001 end *************");
console.info(TAG + "Delete done: " + ret) console.info(TAG + "Delete done: " + ret)
}).catch((err) => { }).catch((err) => {
expect(null).assertFail() expect(null).assertFail();
done();
}) })
await deletePromise
} }
done()
console.info(TAG + "************* testRdbTransactionDelete0001 end *************");
}) })
console.info(TAG + "*************Unit Test End*************"); console.info(TAG + "*************Unit Test End*************");
})} })}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册