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

!2139 【Distributeddatamgr】【Master】API覆盖率补齐

Merge pull request !2139 from 杨立峰/master
...@@ -27,7 +27,7 @@ const CREATE_TABLE_ALL_DATA_TYPE_SQL = "CREATE TABLE IF NOT EXISTS AllDataType " ...@@ -27,7 +27,7 @@ const CREATE_TABLE_ALL_DATA_TYPE_SQL = "CREATE TABLE IF NOT EXISTS AllDataType "
+ "primBooleanValue INTEGER , primByteValue INTEGER , primCharValue TEXT, `order` INTEGER);"; + "primBooleanValue INTEGER , primByteValue INTEGER , primCharValue TEXT, `order` INTEGER);";
const STORE_CONFIG = { const STORE_CONFIG = {
name: "DataAbilityPredicates.db", name: "Predicates.db",
} }
var rdbStore = undefined; var rdbStore = undefined;
var DOUBLE_MAX = 9223372036854775807; var DOUBLE_MAX = 9223372036854775807;
...@@ -53,7 +53,7 @@ describe('dataAbilityPredicatesTest', function () { ...@@ -53,7 +53,7 @@ describe('dataAbilityPredicatesTest', function () {
afterAll(async function () { afterAll(async function () {
console.info(TAG + 'afterAll') console.info(TAG + 'afterAll')
rdbStore = null rdbStore = null
await dataRdb.deleteRdbStore("DataAbilityPredicates.db"); await dataRdb.deleteRdbStore("Predicates.db");
}) })
function resultSize(resultSet) { function resultSize(resultSet) {
...@@ -1238,6 +1238,216 @@ describe('dataAbilityPredicatesTest', function () { ...@@ -1238,6 +1238,216 @@ describe('dataAbilityPredicatesTest', function () {
console.log(TAG + "************* testBetween0008 end *************"); console.log(TAG + "************* testBetween0008 end *************");
}) })
/**
* @tc.name testNotBetween0001
* @tc.number I4JWCV
* @tc.desc test string value with notBetween.
*/
it('testNotBetween0001', 0, async function (done) {
console.log(TAG + "************* testNotBetween0001 start *************");
{
let dataAbilityPredicates = await new dataAbility.DataAbilityPredicates();
dataAbilityPredicates.notBetween("stringValue", "ABB", "ABD");
let predicates = dataAbility.createRdbPredicates("AllDataType", dataAbilityPredicates);
let result = await rdbStore.query(predicates);
expect(0).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testNotBetween0001 end *************");
})
/**
* @tc.name testNotBetween0002
* @tc.number I4JWCV
* @tc.desc test double value with notBetween.
*/
it('testNotBetween0002', 0, async function (done) {
console.log(TAG + "************* testNotBetween0002 start *************");
{
let dataAbilityPredicates = await new dataAbility.DataAbilityPredicates();
dataAbilityPredicates.notBetween("doubleValue", 0.0, DOUBLE_MAX);
let predicates = dataAbility.createRdbPredicates("AllDataType", dataAbilityPredicates);
let result = await rdbStore.query(predicates);
expect(0).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testNotBetween0002 end *************");
})
/**
* @tc.name testNotBetween0003
* @tc.number I4JWCV
* @tc.desc test integer value with notBetween.
*/
it('testNotBetween0003', 0, async function (done) {
console.log(TAG + "************* testNotBetween0003 start *************");
{
let dataAbilityPredicates = await new dataAbility.DataAbilityPredicates();
dataAbilityPredicates.notBetween("integerValue", 0, 1);
let predicates = dataAbility.createRdbPredicates("AllDataType", dataAbilityPredicates);
let result = await rdbStore.query(predicates);
expect(2).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testNotBetween0003 end *************");
})
/**
* @tc.name testNotBetween0004
* @tc.number I4JWCV
* @tc.desc test long value with notBetween.
*/
it('testNotBetween0004', 0, async function (done) {
console.log(TAG + "************* testNotBetween0004 start *************");
{
let dataAbilityPredicates = await new dataAbility.DataAbilityPredicates();
dataAbilityPredicates.notBetween("longValue", 0, 2);
let predicates = dataAbility.createRdbPredicates("AllDataType", dataAbilityPredicates);
let result = await rdbStore.query(predicates);
expect(2).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testNotBetween0004 end *************");
})
/**
* @tc.name testGlob0001
* @tc.number I4JWCV
* @tc.desc end with ? by glob.
*/
it('testGlob0001', 0, async function (done) {
console.log(TAG + "************* testGlob0001 start *************");
{
let dataAbilityPredicates = await new dataAbility.DataAbilityPredicates();
dataAbilityPredicates.glob("stringValue", "ABC*");
let predicates = dataAbility.createRdbPredicates("AllDataType", dataAbilityPredicates);
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testGlob0001 end *************");
})
/**
* @tc.name testGlob0002
* @tc.number I4JWCV
* @tc.desc begin with * by glob.
*/
it('testGlob0002', 0, async function (done) {
console.log(TAG + "************* testGlob0002 start *************");
{
let dataAbilityPredicates = await new dataAbility.DataAbilityPredicates();
dataAbilityPredicates.glob("stringValue", "*LMN");
let predicates = dataAbility.createRdbPredicates("AllDataType", dataAbilityPredicates);
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testGlob0002 end *************");
})
/**
* @tc.name testGlob0003
* @tc.number I4JWCV
* @tc.desc end with ? by glob.
*/
it('testGlob0003', 0, async function (done) {
console.log(TAG + "************* testGlob0003 start *************");
{
let dataAbilityPredicates = await new dataAbility.DataAbilityPredicates();
dataAbilityPredicates.glob("stringValue", "ABCDEFGHIJKLM?");
let predicates = dataAbility.createRdbPredicates("AllDataType", dataAbilityPredicates);
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testGlob0003 end *************");
})
/**
* @tc.name testGlob0004
* @tc.number I4JWCV
* @tc.desc begin with ? by glob.
*/
it('testGlob0004', 0, async function (done) {
console.log(TAG + "************* testGlob0004 start *************");
{
let dataAbilityPredicates = await new dataAbility.DataAbilityPredicates();
dataAbilityPredicates.glob("stringValue", "?BCDEFGHIJKLMN");
let predicates = dataAbility.createRdbPredicates("AllDataType", dataAbilityPredicates);
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testGlob0004 end *************");
})
/**
* @tc.name testGlob0005
* @tc.number I4JWCV
* @tc.desc begin and end with * by glob.
*/
it('testGlob0005', 0, async function (done) {
console.log(TAG + "************* testGlob0005 start *************");
{
let dataAbilityPredicates = await new dataAbility.DataAbilityPredicates();
dataAbilityPredicates.glob("stringValue", "*FGHI*");
let predicates = dataAbility.createRdbPredicates("AllDataType", dataAbilityPredicates);
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testGlob0005 end *************");
})
/**
* @tc.name testGlob0006
* @tc.number I4JWCV
* @tc.desc begin and end with ? by glob.
*/
it('testGlob0006', 0, async function (done) {
console.log(TAG + "************* testGlob0006 start *************");
{
let dataAbilityPredicates = await new dataAbility.DataAbilityPredicates();
dataAbilityPredicates.glob("stringValue", "?BCDEFGHIJKLM?");
let predicates = dataAbility.createRdbPredicates("AllDataType", dataAbilityPredicates);
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testGlob0006 end *************");
})
/** /**
* @tc.name predicates contains normal test * @tc.name predicates contains normal test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_DataAbilityPredicates_0100 * @tc.number SUB_DDM_AppDataFWK_JSRDB_DataAbilityPredicates_0100
...@@ -2098,5 +2308,62 @@ describe('dataAbilityPredicatesTest', function () { ...@@ -2098,5 +2308,62 @@ describe('dataAbilityPredicatesTest', function () {
done(); done();
console.log(TAG + "************* testIndexedBy0002 end *************"); console.log(TAG + "************* testIndexedBy0002 end *************");
}) })
/**
* @tc.name testNotIn0001
* @tc.number I4JWCV
* @tc.desc the common and min value test with notin.
*/
it('testNotIn0001', 0, async function (done) {
console.log(TAG + "************* testNotIn0001 start *************");
var values = [1, -2147483648];
let dataAbilityPredicates = await new dataAbility.DataAbilityPredicates();
dataAbilityPredicates.notIn("integerValue", values);
let predicates = dataAbility.createRdbPredicates("AllDataType", dataAbilityPredicates);
let result = await rdbStore.query(predicates);
expect(1).assertEqual(result.rowCount);
result.close();
done();
console.log(TAG + "************* testNotIn0001 end *************");
})
/**
* @tc.name testNotIn0002
* @tc.number I4JWCV
* @tc.desc the common and max value test with notin.
*/
it('testNotIn0002', 0, async function (done) {
console.log(TAG + "************* testNotIn0002 start *************");
let values = [1, 2147483647];
let dataAbilityPredicates = await new dataAbility.DataAbilityPredicates();
dataAbilityPredicates.notIn("integerValue", values);
let predicates = dataAbility.createRdbPredicates("AllDataType", dataAbilityPredicates);
let result = await rdbStore.query(predicates);
expect(1).assertEqual(result.rowCount);
result.close();
done();
console.log(TAG + "************* testNotIn0002 end *************");
})
/**
* @tc.name testNotIn0003
* @tc.number I4JWCV
* @tc.desc the min and max value test with notin.
*/
it('testNotIn0003', 0, async function (done) {
console.log(TAG + "************* testNotIn0003 start *************");
var values = [-2147483648, 2147483647];
let dataAbilityPredicates = await new dataAbility.DataAbilityPredicates();
dataAbilityPredicates.notIn("integerValue", values);
let predicates = dataAbility.createRdbPredicates("AllDataType", dataAbilityPredicates);
let result = await rdbStore.query(predicates);
expect(1).assertEqual(result.rowCount);
result.close();
done();
console.log(TAG + "************* testNotIn0003 end *************");
})
console.log(TAG + "*************Unit Test End*************"); console.log(TAG + "*************Unit Test End*************");
}) })
...@@ -27,3 +27,5 @@ require('./DataAbilityPredicatesJsunit.test.js') ...@@ -27,3 +27,5 @@ require('./DataAbilityPredicatesJsunit.test.js')
require('./RdbstoreTransactionJsunit.test.js') require('./RdbstoreTransactionJsunit.test.js')
require('./RdbstorePredicatesJoinJsunit.test.js') require('./RdbstorePredicatesJoinJsunit.test.js')
require('./RdbStoreDistributedJsunit.test.js') require('./RdbStoreDistributedJsunit.test.js')
require('./DataShareJsunit.test.js')
...@@ -301,7 +301,10 @@ describe('rdbStoreDistributedTest', function () { ...@@ -301,7 +301,10 @@ describe('rdbStoreDistributedTest', function () {
let predicates = new dataRdb.RdbPredicates("employee") let predicates = new dataRdb.RdbPredicates("employee")
predicates = predicates.inDevices("12345678abcd"); predicates = predicates.inDevices("12345678abcd");
rdbStore.sync(dataRdb.SyncMode.SYNC_MODE_PUSH, predicates); rdbStore.sync(dataRdb.SyncMode.SYNC_MODE_PUSH, predicates);
console.log(TAG + "sync success"); console.log(TAG + "sync push success");
expect(rdbStore).assertEqual(rdbStore);
rdbStore.sync(dataRdb.SyncMode.SYNC_MODE_PULL, predicates);
console.log(TAG + "sync pull success");
expect(rdbStore).assertEqual(rdbStore); expect(rdbStore).assertEqual(rdbStore);
done(); done();
console.log(TAG + "************* testRdbStoreDistributed0011 end *************"); console.log(TAG + "************* testRdbStoreDistributed0011 end *************");
......
...@@ -1121,6 +1121,196 @@ describe('rdbPredicatesTest', function () { ...@@ -1121,6 +1121,196 @@ describe('rdbPredicatesTest', function () {
console.log(TAG + "************* testBetween0008 end *************"); console.log(TAG + "************* testBetween0008 end *************");
}) })
/**
* @tc.name testNotBetween0001
* @tc.number I4JWCV
* @tc.desc test string value with notBetween.
*/
it('testNotBetween0001', 0, async function (done) {
console.log(TAG + "************* testNotBetween0001 start *************");
{
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.notBetween("stringValue", "ABB", "ABD");
let result = await rdbStore.query(predicates);
expect(0).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testNotBetween0001 end *************");
})
/**
* @tc.name testNotBetween0002
* @tc.number I4JWCV
* @tc.desc test double value with notBetween.
*/
it('testNotBetween0002', 0, async function (done) {
console.log(TAG + "************* testNotBetween0002 start *************");
{
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.notBetween("doubleValue", 0.0, DOUBLE_MAX);
let result = await rdbStore.query(predicates);
expect(0).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testNotBetween0002 end *************");
})
/**
* @tc.name testNotBetween0003
* @tc.number I4JWCV
* @tc.desc test integer value with notBetween.
*/
it('testNotBetween0003', 0, async function (done) {
console.log(TAG + "************* testNotBetween0003 start *************");
{
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.notBetween("integerValue", 0, 1);
let result = await rdbStore.query(predicates);
expect(2).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testNotBetween0003 end *************");
})
/**
* @tc.name testNotBetween0004
* @tc.number I4JWCV
* @tc.desc test long value with notBetween.
*/
it('testNotBetween0004', 0, async function (done) {
console.log(TAG + "************* testNotBetween0004 start *************");
{
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.notBetween("longValue", 0, 2);
let result = await rdbStore.query(predicates);
expect(2).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testNotBetween0004 end *************");
})
/**
* @tc.name testGlob0001
* @tc.number I4JWCV
* @tc.desc end with ? by glob.
*/
it('testGlob0001', 0, async function (done) {
console.log(TAG + "************* testGlob0001 start *************");
{
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.glob("stringValue", "ABC*");
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testGlob0001 end *************");
})
/**
* @tc.name testGlob0002
* @tc.number I4JWCV
* @tc.desc begin with * by glob.
*/
it('testGlob0002', 0, async function (done) {
console.log(TAG + "************* testGlob0002 start *************");
{
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.glob("stringValue", "*LMN");
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testGlob0002 end *************");
})
/**
* @tc.name testGlob0003
* @tc.number I4JWCV
* @tc.desc end with ? by glob.
*/
it('testGlob0003', 0, async function (done) {
console.log(TAG + "************* testGlob0003 start *************");
{
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.glob("stringValue", "ABCDEFGHIJKLM?");
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testGlob0003 end *************");
})
/**
* @tc.name testGlob0004
* @tc.number I4JWCV
* @tc.desc begin with ? by glob.
*/
it('testGlob0004', 0, async function (done) {
console.log(TAG + "************* testGlob0004 start *************");
{
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.glob("stringValue", "?BCDEFGHIJKLMN");
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testGlob0004 end *************");
})
/**
* @tc.name testGlob0005
* @tc.number I4JWCV
* @tc.desc begin and end with * by glob.
*/
it('testGlob0005', 0, async function (done) {
console.log(TAG + "************* testGlob0005 start *************");
{
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.glob("stringValue", "*FGHI*");
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testGlob0005 end *************");
})
/**
* @tc.name testGlob0006
* @tc.number I4JWCV
* @tc.desc begin and end with ? by glob.
*/
it('testGlob0006', 0, async function (done) {
console.log(TAG + "************* testGlob0006 start *************");
{
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.glob("stringValue", "?BCDEFGHIJKLM?");
let result = await rdbStore.query(predicates);
expect(3).assertEqual(result.rowCount);
result.close();
result = null
}
done();
console.log(TAG + "************* testGlob0006 end *************");
})
/** /**
* @tc.name predicates contains normal test * @tc.name predicates contains normal test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0100 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0100
...@@ -1866,6 +2056,57 @@ describe('rdbPredicatesTest', function () { ...@@ -1866,6 +2056,57 @@ describe('rdbPredicatesTest', function () {
console.log(TAG + "************* testIn0004 end *************"); console.log(TAG + "************* testIn0004 end *************");
}) })
/**
* @tc.name testNotIn0001
* @tc.number I4JWCV
* @tc.desc the common and min value test with notin.
*/
it('testNotIn0001', 0, async function (done) {
console.log(TAG + "************* testNotIn0001 start *************");
var values = [1, -2147483648];
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.notIn("integerValue", values);
let result = await rdbStore.query(predicates);
expect(1).assertEqual(result.rowCount);
result.close();
done();
console.log(TAG + "************* testNotIn0001 end *************");
})
/**
* @tc.name testNotIn0002
* @tc.number I4JWCV
* @tc.desc the common and max value test with notin.
*/
it('testNotIn0002', 0, async function (done) {
console.log(TAG + "************* testNotIn0002 start *************");
let values = [1, 2147483647];
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.notIn("integerValue", values);
let result = await rdbStore.query(predicates);
expect(1).assertEqual(result.rowCount);
result.close();
done();
console.log(TAG + "************* testNotIn0002 end *************");
})
/**
* @tc.name testNotIn0003
* @tc.number I4JWCV
* @tc.desc the min and max value test with notin.
*/
it('testNotIn0003', 0, async function (done) {
console.log(TAG + "************* testNotIn0003 start *************");
var values = [-2147483648, 2147483647];
let predicates = await new dataRdb.RdbPredicates("AllDataType");
predicates.notIn("integerValue", values);
let result = await rdbStore.query(predicates);
expect(1).assertEqual(result.rowCount);
result.close();
done();
console.log(TAG + "************* testNotIn0003 end *************");
})
/** /**
* @tc.name predicates constructor test * @tc.name predicates constructor test
* @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0200 * @tc.number SUB_DDM_AppDataFWK_JSRDB_Predicates_0200
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册