提交 d69fbac8 编写于 作者: Y yanglifeng1217

<modified>

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