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

!9243 【Distributeddatamgr】【Master】rdb用例补充

Merge pull request !9243 from lina123456/master
...@@ -39,6 +39,7 @@ describe('rdbPredicatesTest', function () { ...@@ -39,6 +39,7 @@ describe('rdbPredicatesTest', function () {
await buildAllDataType1(); await buildAllDataType1();
await buildAllDataType2(); await buildAllDataType2();
await buildAllDataType3(); await buildAllDataType3();
await rdbStore.executeSql("CREATE INDEX index_name ON AllDataType (characterValue);", null);
}) })
beforeEach(function () { beforeEach(function () {
...@@ -2173,48 +2174,88 @@ describe('rdbPredicatesTest', function () { ...@@ -2173,48 +2174,88 @@ describe('rdbPredicatesTest', function () {
}) })
/** /**
* @tc.name predicates indexedBy test * @tc.name predicates indexedBy test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0220 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0220
* @tc.desc predicates indexedBy test * @tc.desc predicates indexedBy test
*/ */
it('testIndexedBy0001', 0, async function (done) { it('testIndexedBy0001', 0, async function (done) {
console.info(TAG + "************* testIndexedBy0001 start *************"); console.info(TAG + "************* testIndexedBy0001 start *************");
let errInfo = undefined try{
try{ let predicates = await new dataRdb.RdbPredicates("AllDataType");
let predicates = await new dataRdb.RdbPredicates("AllDataType"); predicates.like("stringValue", "ABCDEFGHIJKLMN").indexedBy(["characterValue"]);
predicates.like("stringValue", "ABCDEFGHIJKLMN").indexedBy(["characterValue"]); let result = await rdbStore.query(predicates);
let result = await rdbStore.query(predicates); expect(result.rowCount == -1).assertTrue();
expect(3).assertEqual(result.rowCount); done();
} catch (err) { } catch (err) {
expect(err != undefined).assertTrue(); expect(err != undefined).assertTrue();
console.info(TAG + "testIndexedBy0001 err " + err); console.info(TAG + "testIndexedBy0001 err " + err);
errInfo = err; done();
} }
done(); console.info(TAG + "************* testIndexedBy0001 end *************");
console.info(TAG + "************* testIndexedBy0001 end *************"); })
})
/**
/** * @tc.name predicates indexedBy test
* @tc.name predicates indexedBy test * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0221
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0221 * @tc.desc predicates indexedBy test
* @tc.desc predicates indexedBy test */
*/ it('testIndexedBy0002', 0, async function (done) {
it('testIndexedBy0002', 0, async function (done) { console.info(TAG + "************* testIndexedBy0002 start *************");
console.info(TAG + "************* testIndexedBy0002 start *************"); try{
let errInfo = undefined let predicates = await new dataRdb.RdbPredicates("AllDataType");
try{ predicates.like("stringValue", "ABCDEFGHIJKLMN").indexedBy("characterValue");
let predicates = await new dataRdb.RdbPredicates("AllDataType"); let result = await rdbStore.query(predicates);
predicates.like("stringValue", "ABCDEFGHIJKLMN").indexedBy(["characterValueX"]); expect(result.rowCount == -1).assertTrue();
let result = await rdbStore.query(predicates); done();
expect(3).assertEqual(result.rowCount); } catch (err) {
} catch (err) { expect(err != undefined).assertTrue();
expect(err != undefined).assertTrue(); console.info(TAG + "testIndexedBy0002 err " + err);
console.info(TAG + "testIndexedBy0002 err " + err); done();
errInfo = err; }
} console.info(TAG + "************* testIndexedBy0002 end *************");
done(); })
console.info(TAG + "************* testIndexedBy0002 end *************");
}) /**
* @tc.name predicates indexedBy test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0222
* @tc.desc predicates indexedBy test
*/
it('testIndexedBy0003', 0, async function (done) {
console.info(TAG + "************* testIndexedBy0003 start *************");
try{
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.indexedBy("index_name");
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
done();
} catch (err) {
expect(err != undefined).assertFail();
console.info(TAG + "testIndexedBy0003 err " + err);
done();
}
console.info(TAG + "************* testIndexedBy0003 end *************");
})
/**
* @tc.name predicates indexedBy test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0223
* @tc.desc predicates indexedBy test
*/
it('testIndexedBy0004', 0, async function (done) {
console.info(TAG + "************* testIndexedBy0004 start *************");
try{
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.like("stringValue", "ABCDEFGHIJKLMN").indexedBy("index_name");
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
done();
} catch (err) {
expect(err != undefined).assertFail();
console.info(TAG + "testIndexedBy0004 err " + err);
done();
}
console.info(TAG + "************* testIndexedBy0004 end *************");
})
console.info(TAG + "*************Unit Test End*************"); console.info(TAG + "*************Unit Test End*************");
})} })}
...@@ -42,6 +42,7 @@ describe('relationalStorePredicatesTest', function () { ...@@ -42,6 +42,7 @@ describe('relationalStorePredicatesTest', function () {
await buildAllDataType1(); await buildAllDataType1();
await buildAllDataType2(); await buildAllDataType2();
await buildAllDataType3(); await buildAllDataType3();
await rdbStore.executeSql("CREATE INDEX index_name ON AllDataType (characterValue);", null);
}) })
beforeEach(function () { beforeEach(function () {
...@@ -2174,48 +2175,92 @@ describe('relationalStorePredicatesTest', function () { ...@@ -2174,48 +2175,92 @@ describe('relationalStorePredicatesTest', function () {
}) })
/** /**
* @tc.name predicates indexedBy test * @tc.name predicates indexedBy test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Predicates_0220 * @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Predicates_0220
* @tc.desc predicates indexedBy test * @tc.desc predicates indexedBy test
*/ */
it('testIndexedBy0001', 0, async function (done) { it('testIndexedBy0001', 0, async function (done) {
console.info(TAG + "************* testIndexedBy0001 start *************"); console.info(TAG + "************* testIndexedBy0001 start *************");
let errInfo = undefined try{
try{ let predicates = await new data_Rdb.RdbPredicates("AllDataType");
let predicates = await new data_Rdb.RdbPredicates("AllDataType"); predicates.like("stringValue", "ABCDEFGHIJKLMN").indexedBy(["characterValue"]);
predicates.like("stringValue", "ABCDEFGHIJKLMN").indexedBy(["characterValue"]); let result = await rdbStore.query(predicates);
let result = await rdbStore.query(predicates); expect(result.rowCount == -1).assertTrue();
expect(3).assertEqual(result.rowCount); result.close();
result.close(); done();
}catch(err){ }catch(err){
errInfo = err expect(err.code).assertEqual("401");
} done();
expect(errInfo.code).assertEqual("401") }
done(); console.info(TAG + "************* testIndexedBy0001 end *************");
console.info(TAG + "************* testIndexedBy0001 end *************"); })
})
/**
/** * @tc.name predicates indexedBy test
* @tc.name predicates indexedBy test * @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Predicates_0221
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Predicates_0221 * @tc.desc predicates indexedBy test
* @tc.desc predicates indexedBy test */
*/ it('testIndexedBy0002', 0, async function (done) {
it('testIndexedBy0002', 0, async function (done) { console.info(TAG + "************* testIndexedBy0002 start *************");
console.info(TAG + "************* testIndexedBy0002 start *************"); try{
let errInfo = undefined let predicates = await new data_Rdb.RdbPredicates("AllDataType");
try{ predicates.like("stringValue", "ABCDEFGHIJKLMN").indexedBy("characterValue");
let predicates = await new data_Rdb.RdbPredicates("AllDataType"); let result = await rdbStore.query(predicates);
predicates.like("stringValue", "ABCDEFGHIJKLMN").indexedBy(["characterValueX"]); expect(result.rowCount == -1).assertTrue();
let result = await rdbStore.query(predicates); result.close();
expect(3).assertEqual(result.rowCount); done();
result.close(); }catch(err){
}catch(err){ expect(err != undefined ).assertFalse();
errInfo = err done();
} }
expect(errInfo.code).assertEqual("401") console.info(TAG + "************* testIndexedBy0002 end *************");
done(); })
console.info(TAG + "************* testIndexedBy0002 end *************");
}) /**
* @tc.name predicates indexedBy test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Predicates_0222
* @tc.desc predicates indexedBy test
*/
it('testIndexedBy0003', 0, async function (done) {
console.info(TAG + "************* testIndexedBy0003 start *************");
try{
let predicates = await new data_Rdb.RdbPredicates("AllDataType");
predicates.indexedBy("index_name");
let result = await rdbStore.query(predicates);
console.info(TAG + "result.rowCount = " + result.rowCount);
expect(3).assertEqual(result.rowCount);
result.close();
done();
}catch(err){
console.info(TAG + "err = " + err);
expect(err != undefined ).assertFalse();
done();
}
console.info(TAG + "************* testIndexedBy0003 end *************");
})
/**
* @tc.name predicates indexedBy test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Predicates_0223
* @tc.desc predicates indexedBy test
*/
it('testIndexedBy0004', 0, async function (done) {
console.info(TAG + "************* testIndexedBy0004 start *************");
try{
let predicates = await new data_Rdb.RdbPredicates("AllDataType");
predicates.like("stringValue", "ABCDEFGHIJKLMN").indexedBy("index_name");
let result = await rdbStore.query(predicates);
console.info(TAG + "result.rowCount = " + result.rowCount);
expect(3).assertEqual(result.rowCount);
result.close();
done();
}catch(err){
console.info(TAG + "err = " + err);
expect(err != undefined ).assertFalse();
done();
}
console.info(TAG + "************* testIndexedBy0004 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.
先完成此消息的编辑!
想要评论请 注册