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

!5222 【Distributeddatamgr】【monthly_20220816】解决用例失败问题

Merge pull request !5222 from 梁梁/monthly_20220816
...@@ -214,20 +214,21 @@ describe('rdbResultSetTest', function () { ...@@ -214,20 +214,21 @@ describe('rdbResultSetTest', function () {
* @tc.desc resultSet isStarted normal test * @tc.desc resultSet isStarted normal test
*/ */
it('testIsStarted0003', 0, async function (done) { it('testIsStarted0003', 0, async function (done) {
console.info(TAG + '************* testIsStarted0003 start *************'); console.info(TAG + "************* testIsStarted0003 start *************");
let predicates = await new dataRdb.RdbPredicates('test') let predicates = await new dataRdb.RdbPredicates("test")
let resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
try { try {
expect(false).assertEqual(resultSet.isStarted)
expect(true).assertEqual(resultSet.goToNextRow()) expect(true).assertEqual(resultSet.goToNextRow())
expect(true).assertEqual(resultSet.isStarted) expect(true).assertEqual(resultSet.isStarted)
expect(false).assertEqual(resultSet.goToPreviousRow()) expect(false).assertEqual(resultSet.goToPreviousRow())
expect(false).assertEqual(resultSet.isStarted) expect(true).assertEqual(resultSet.isStarted)
} catch (e) { } catch (e) {
expect(null).assertFail(); expect(null).assertFail();
} }
resultSet = null resultSet = null
done(); done();
console.info(TAG + '************* testIsStarted0003 end *************'); console.info(TAG + "************* testIsStarted0003 end *************");
}) })
/** /**
......
...@@ -25,6 +25,7 @@ const STORE_CONFIG = { ...@@ -25,6 +25,7 @@ const STORE_CONFIG = {
} }
var rdbStore = undefined; var rdbStore = undefined;
var resultSet = undefined;
function sleep(ms) { function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms)); return new Promise(resolve => setTimeout(resolve, ms));
...@@ -320,7 +321,7 @@ describe('rdbstoreInsertTest', function () { ...@@ -320,7 +321,7 @@ describe('rdbstoreInsertTest', function () {
}) })
let predicates = new dataRdb.RdbPredicates("test2"); let predicates = new dataRdb.RdbPredicates("test2");
predicates.equalTo("name", "lisi") predicates.equalTo("name", "lisi")
resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
try { try {
console.info(TAG + "resultSet query done"); console.info(TAG + "resultSet query done");
expect(true).assertEqual(resultSet.goToFirstRow()) expect(true).assertEqual(resultSet.goToFirstRow())
...@@ -334,11 +335,11 @@ describe('rdbstoreInsertTest', function () { ...@@ -334,11 +335,11 @@ describe('rdbstoreInsertTest', function () {
expect("lisi").assertEqual(name) expect("lisi").assertEqual(name)
expect(23).assertEqual(age) expect(23).assertEqual(age)
expect(200).assertEqual(salary) expect(200).assertEqual(salary)
await rdbstore.delete(predicates).then((number) => { await rdbStore.delete(predicates).then((number) => {
expect(1).assertEqual(number) expect(1).assertEqual(number)
}).then(async () => { }).then(async () => {
resultSet = await rdbStore.query(predicates).catch((err) =>{ resultSet = await rdbStore.query(predicates).catch((err) =>{
expect(true).assertTrue(); expect(err != null).assertTrue();
}) })
}) })
} catch (e) { } catch (e) {
...@@ -393,6 +394,7 @@ describe('rdbstoreInsertTest', function () { ...@@ -393,6 +394,7 @@ describe('rdbstoreInsertTest', function () {
const name = resultSet.getString(resultSet.getColumnIndex("name")) const name = resultSet.getString(resultSet.getColumnIndex("name"))
const age = resultSet.getLong(resultSet.getColumnIndex("age")) const age = resultSet.getLong(resultSet.getColumnIndex("age"))
const salary = resultSet.getDouble(resultSet.getColumnIndex("salary")) const salary = resultSet.getDouble(resultSet.getColumnIndex("salary"))
const blobType = resultSet.getBlob(resultSet.getColumnIndex("blobType"))
console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary + ", blobType=" + blobType); console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary + ", blobType=" + blobType);
expect(1).assertEqual(id); expect(1).assertEqual(id);
expect("zhangsan").assertEqual(name) expect("zhangsan").assertEqual(name)
...@@ -414,6 +416,7 @@ describe('rdbstoreInsertTest', function () { ...@@ -414,6 +416,7 @@ describe('rdbstoreInsertTest', function () {
const name = resultSet.getString(resultSet.getColumnIndex("name")) const name = resultSet.getString(resultSet.getColumnIndex("name"))
const age = resultSet.getLong(resultSet.getColumnIndex("age")) const age = resultSet.getLong(resultSet.getColumnIndex("age"))
const salary = resultSet.getDouble(resultSet.getColumnIndex("salary")) const salary = resultSet.getDouble(resultSet.getColumnIndex("salary"))
const blobType = resultSet.getBlob(resultSet.getColumnIndex("blobType"))
console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary + ", blobType=" + blobType); console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary + ", blobType=" + blobType);
expect(2).assertEqual(id); expect(2).assertEqual(id);
expect("lisi").assertEqual(name) expect("lisi").assertEqual(name)
...@@ -425,7 +428,7 @@ describe('rdbstoreInsertTest', function () { ...@@ -425,7 +428,7 @@ describe('rdbstoreInsertTest', function () {
"salary": 500, "salary": 500,
"blobType": u8, "blobType": u8,
} }
await rdbstore.insert("test3",valueBucket4) await rdbStore.insert("test3",valueBucket4)
predicates = new dataRdb.RdbPredicates("test3"); predicates = new dataRdb.RdbPredicates("test3");
predicates.equalTo("name", "zhangmaowen") predicates.equalTo("name", "zhangmaowen")
resultSet = await rdbStore.query(predicates) resultSet = await rdbStore.query(predicates)
...@@ -488,6 +491,7 @@ describe('rdbstoreInsertTest', function () { ...@@ -488,6 +491,7 @@ describe('rdbstoreInsertTest', function () {
const name = resultSet.getString(resultSet.getColumnIndex("name")) const name = resultSet.getString(resultSet.getColumnIndex("name"))
const age = resultSet.getLong(resultSet.getColumnIndex("age")) const age = resultSet.getLong(resultSet.getColumnIndex("age"))
const salary = resultSet.getDouble(resultSet.getColumnIndex("salary")) const salary = resultSet.getDouble(resultSet.getColumnIndex("salary"))
const blobType = resultSet.getBlob(resultSet.getColumnIndex("blobType"))
console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary + ", blobType=" + blobType); console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary + ", blobType=" + blobType);
expect(56).assertEqual(id); expect(56).assertEqual(id);
expect("zhangsan55").assertEqual(name) expect("zhangsan55").assertEqual(name)
...@@ -594,11 +598,11 @@ describe('rdbstoreInsertTest', function () { ...@@ -594,11 +598,11 @@ describe('rdbstoreInsertTest', function () {
const valueBuckets = [valueBucket1, valueBucket2, valueBucket3] const valueBuckets = [valueBucket1, valueBucket2, valueBucket3]
try{ try{
await rdbStore.batchInsert("test6","valueBuckets").catch((err) =>{ await rdbStore.batchInsert("test6","valueBuckets").catch((err) =>{
expect(true).assertTrue(); expect(err != null).assertTrue();
}) })
}catch(err){ }catch(err){
console.info(TAG + "Batch insert data error: " + err) console.info(TAG + "Batch insert data error: " + err)
expect(true).assertTrue(); expect(err != null).assertTrue();
} }
done() done()
console.info(TAG + "************* testRdbStorebatchInsertPromise0006 end *************"); console.info(TAG + "************* testRdbStorebatchInsertPromise0006 end *************");
...@@ -614,11 +618,11 @@ describe('rdbstoreInsertTest', function () { ...@@ -614,11 +618,11 @@ describe('rdbstoreInsertTest', function () {
await rdbStore.executeSql(CREATE_TABLE_NAME + "7" + CREATE_TABLE) await rdbStore.executeSql(CREATE_TABLE_NAME + "7" + CREATE_TABLE)
try{ try{
await rdbStore.batchInsert("test7").catch((err) =>{ await rdbStore.batchInsert("test7").catch((err) =>{
expect(true).assertTrue(); expect(err != null).assertTrue();
}) })
}catch(err){ }catch(err){
console.info(TAG + "Batch insert data error: " + err) console.info(TAG + "Batch insert data error: " + err)
expect(true).assertTrue(); expect(err != null).assertTrue();
} }
done() done()
console.info(TAG + "************* testRdbStorebatchInsertPromise0007 end *************"); console.info(TAG + "************* testRdbStorebatchInsertPromise0007 end *************");
...@@ -748,7 +752,7 @@ describe('rdbstoreInsertTest', function () { ...@@ -748,7 +752,7 @@ describe('rdbstoreInsertTest', function () {
expect(3).assertEqual(data) expect(3).assertEqual(data)
let predicates = new dataRdb.RdbPredicates("testCallback2"); let predicates = new dataRdb.RdbPredicates("testCallback2");
predicates.equalTo("name", "lisi") predicates.equalTo("name", "lisi")
resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
try { try {
console.info(TAG + "resultSet query done"); console.info(TAG + "resultSet query done");
expect(true).assertEqual(resultSet.goToFirstRow()) expect(true).assertEqual(resultSet.goToFirstRow())
...@@ -762,11 +766,11 @@ describe('rdbstoreInsertTest', function () { ...@@ -762,11 +766,11 @@ describe('rdbstoreInsertTest', function () {
expect("lisi").assertEqual(name) expect("lisi").assertEqual(name)
expect(23).assertEqual(age) expect(23).assertEqual(age)
expect(200).assertEqual(salary) expect(200).assertEqual(salary)
await rdbstore.delete(predicates).then((number) => { await rdbStore.delete(predicates).then((number) => {
expect(1).assertEqual(number) expect(1).assertEqual(number)
}).then(async () => { }).then(async () => {
resultSet = await rdbStore.query(predicates).catch((err) =>{ resultSet = await rdbStore.query(predicates).catch((err) =>{
expect(true).assertTrue(); expect(err != null).assertTrue();
}) })
}) })
} catch (e) { } catch (e) {
...@@ -856,7 +860,7 @@ describe('rdbstoreInsertTest', function () { ...@@ -856,7 +860,7 @@ describe('rdbstoreInsertTest', function () {
"salary": 500, "salary": 500,
"blobType": u8, "blobType": u8,
} }
await rdbstore.insert("testCallback3",valueBucket4) await rdbStore.insert("testCallback3",valueBucket4)
predicates = new dataRdb.RdbPredicates("testCallback3"); predicates = new dataRdb.RdbPredicates("testCallback3");
predicates.equalTo("name", "zhangmaowen") predicates.equalTo("name", "zhangmaowen")
resultSet = await rdbStore.query(predicates) resultSet = await rdbStore.query(predicates)
...@@ -1034,14 +1038,14 @@ describe('rdbstoreInsertTest', function () { ...@@ -1034,14 +1038,14 @@ describe('rdbstoreInsertTest', function () {
try{ try{
await rdbStore.batchInsert("testCallback6", "valueBuckets", (err, data) => { await rdbStore.batchInsert("testCallback6", "valueBuckets", (err, data) => {
if(err != null){ if(err != null){
expect(true).assertTrue() expect(err != null).assertTrue()
}else{ }else{
expect(false).assertTrue() expect(false).assertTrue()
} }
}) })
}catch(err){ }catch(err){
console.info(TAG + "Batch insert data error: " + err) console.info(TAG + "Batch insert data error: " + err)
expect(true).assertTrue(); expect(err != null).assertTrue();
} }
}) })
...@@ -1059,15 +1063,15 @@ describe('rdbstoreInsertTest', function () { ...@@ -1059,15 +1063,15 @@ describe('rdbstoreInsertTest', function () {
console.info(TAG + "************* testRdbStorebatchInsertCallback0007 start *************"); console.info(TAG + "************* testRdbStorebatchInsertCallback0007 start *************");
try{ try{
await rdbStore.executeSql(CREATE_TABLE_NAME + "Callback7" + CREATE_TABLE).then(async () => { await rdbStore.executeSql(CREATE_TABLE_NAME + "Callback7" + CREATE_TABLE).then(async () => {
await rdbstore.batchInsert("testCallback7", (err,data) => { await rdbStore.batchInsert("testCallback7", (err,data) => {
if(err != null){ if(err != null){
expect(true).assertTrue(); expect(err != null).assertTrue();
} }
}) })
}) })
}catch(err){ }catch(err){
console.info(TAG + "Batch insert data error: " + err) console.info(TAG + "Batch insert data error: " + err)
expect(true).assertTrue(); expect(err != null).assertTrue();
} }
done() done()
console.info(TAG + "************* testRdbStorebatchInsertCallback0007 end *************"); console.info(TAG + "************* testRdbStorebatchInsertCallback0007 end *************");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册