提交 d8a4056f 编写于 作者: Y yuxiaoya2

RelationalStoreJsunit.test.test.js 文件新增用例

Signed-off-by: Nyuxiaoya2 <yuxiaoya@huawei.com>
Change-Id: I2460d8b29d6454a27226e6f0d12b26e9e94166fe
上级 de71f2ce
......@@ -17,6 +17,7 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '
import data_Rdb from '@ohos.data.relationalStore';
import ability_featureAbility from '@ohos.ability.featureAbility';
var context = ability_featureAbility.getContext();
var contextApplication = context.getApplicationContext()
const TAG = "[RelationalStore_JSKITS_TEST]"
......@@ -246,6 +247,205 @@ describe('relationalStoreTest', function () {
});
await sleep(1000)
})
/**
* @tc.name RelationalStore store deleteRdbStore test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_RdbStore_0100
* @tc.desc RelationalStore store deleteRdbStore test
*/
it('testRdbStore0010', 0, async function(done){
console.info(TAG + "************* testRdbStore0010 start *************");
await data_Rdb.getRdbStore(contextApplication, STORE_CONFIG, async function(err,rdbStore){
if (err) {
console.info("Get testRdbStore0010 failed, err: " + err)
expect().assertFail();
return
}
if (rdbStore.openStatus == data_Rdb.OpenStatus.ON_CREATE) {
console.log("testRdbStore0010 status is ON_CREATE")
expect(true).assertTrue();
} else if (rdbStore.openStatus == data_Rdb.OpenStatus.ON_OPEN) {
console.log("testRdbStore0010 status is ON_OPEN")
expect().assertFail();
} else {
expect().assertFail();
return
}
console.log("Get testRdbStore0010 successfully.")
});
await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name)
done();
console.log("Get testRdbStore0010 successfully end.")
await sleep(1000)
})
/**
* @tc.name RelationalStore store RelationalStore.OpenStatus test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_RdbStore_0110
* @tc.desc RelationalStore store RelationalStore.OpenStatus test
*/
it('testRdbStore0011', 0, async function(done){
console.info(TAG + "************* testRdbStore0011 start *************");
await data_Rdb.getRdbStore(contextApplication, STORE_CONFIG, async function(err,rdbStore){
if (err) {
console.info("Get testRdbStore0011 failed, err: " + err)
return
}
if (rdbStore.openStatus == data_Rdb.OpenStatus.ON_CREATE) {
console.log("testRdbStore0011 status1 is ON_CREATE")
} else if (rdbStore.openStatus == data_Rdb.OpenStatus.ON_OPEN) {
console.log("testRdbStore0011 status1 is ON_OPEN")
} else {
expect().assertFail();
return
}
});
await data_Rdb.getRdbStore(contextApplication, STORE_CONFIG, async function(err,rdbStore){
if (err) {
console.info("Get testRdbStore0011 failed, err: " + err)
expect().assertFail();
return
}
if (rdbStore.openStatus == data_Rdb.OpenStatus.ON_CREATE) {
console.log("testRdbStore0011 status is ON_CREATE")
expect().assertFail();
} else if (rdbStore.openStatus ==data_Rdb.OpenStatus.ON_OPEN) {
console.log("testRdbStore0011 status is ON_OPEN")
expect(true).assertTrue();
} else {
expect().assertFail();
return
}
});
await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name)
done();
console.log("Get testRdbStore0011 successfully end.")
})
/**
* @tc.name RelationalStore store RelationalStore.OpenStatus test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_RdbStore_0120
* @tc.desc RelationalStore store RelationalStore.OpenStatus test
*/
it('testRdbStore0012', 0, async function(done){
console.info(TAG + "************* testRdbStore0012 start *************");
try{
let promise = null;
promise = await data_Rdb.getRdbStore(context, STORE_CONFIG);
promise =null;
promise = await data_Rdb.getRdbStore(context, STORE_CONFIG);
console.info("Get testRdbStore0012 promise.openStatus: " + promise.openStatus)
console.info("Get testRdbStore0012 data_Rdb.OpenStatus.ON_OPEN: " + data_Rdb.OpenStatus.ON_OPEN)
expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_OPEN);
await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name)
}catch(err){
console.info(TAG + "Get rdbstore fail catch err: " + err)
expect(null).assertFail()
}
done();
console.log("Get testRdbStore0012 successfully end.")
})
/**
* @tc.name RelationalStore store RelationalStore.OpenStatus test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_RdbStore_0130
* @tc.desc RelationalStore store RelationalStore.OpenStatus test
*/
it('testRdbStore0013', 0, async function(done){
console.info(TAG + "************* testRdbStore0013 start *************");
let STORE_CONFIG1 = {
name: "rdbnumber.db",
securityLevel: data_Rdb.SecurityLevel.S1
}
try{
let promise = null;
promise = await data_Rdb.getRdbStore(context, STORE_CONFIG);
console.info("Get testRdbStore0013 STORE_CONFIG promise.openStatus: " + promise.openStatus)
expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_CREATE);
promise = await data_Rdb.getRdbStore(context, STORE_CONFIG1);
console.info("Get testRdbStore0013 STORE_CONFIG1 promise.openStatus: " + promise.openStatus)
expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_CREATE);
}catch(err){
console.info(TAG + "Get testRdbStore0013 fail catch err: " + err)
expect(null).assertFail()
}
await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name)
await data_Rdb.deleteRdbStore(context, STORE_CONFIG1.name)
done();
console.log("Get testRdbStore0013 successfully end.")
})
/**
* @tc.name RelationalStore store RelationalStore.OpenStatus test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_RdbStore_0140
* @tc.desc RelationalStore store RelationalStore.OpenStatus test
*/
it('testRdbStore0014', 0, async function(done){
console.info(TAG + "************* testRdbStore0014 start *************");
let STORE_CONFIG1 = {
name: "rdbnumber.db",
securityLevel: data_Rdb.SecurityLevel.S1
}
try{
let promise = null;
promise = await data_Rdb.getRdbStore(context, STORE_CONFIG);
console.info("Get testRdbStore0014 STORE_CONFIG promise.openStatus: " + promise.openStatus)
expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_CREATE);
// expect(promise.openStatus != data_Rdb.OpenStatus.ON_CREATE).assertFail();
promise = null;
promise = await data_Rdb.getRdbStore(context, STORE_CONFIG1);
console.info("Get testRdbStore0014 STORE_CONFIG1 promise.openStatus: " + promise.openStatus)
// expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_CREATE);
expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_CREATE);
}catch(err){
console.info(TAG + "Get testRdbStore0014 fail catch err: " + err)
expect(null).assertFail()
}
await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name)
await data_Rdb.deleteRdbStore(context, STORE_CONFIG1.name)
done();
console.log("Get testRdbStore0014 successfully end.")
})
/**
* @tc.name RelationalStore store RelationalStore.OpenStatus test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_RdbStore_0150
* @tc.desc RelationalStore store RelationalStore.OpenStatus test
*/
it('testRdbStore0015', 0, async function(done){
console.info(TAG + "************* testRdbStore0012 start *************");
let STORE_CONFIG1 = {
name: "rdbnumber.db",
securityLevel: data_Rdb.SecurityLevel.S1
}
try{
let promise = null;
promise = await data_Rdb.getRdbStore(context, STORE_CONFIG);
console.info("Get testRdbStore0015 STORE_CONFIG promise.openStatus: " + promise.openStatus)
// expect(promise.openStatus != data_Rdb.OpenStatus.ON_CREATE).assertFail();
expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_CREATE);
promise = await data_Rdb.getRdbStore(context, STORE_CONFIG1);
console.info("Get testRdbStore0015 STORE_CONFIG1 promise.openStatus: " + promise.openStatus)
// expect(promise.openStatus != data_Rdb.OpenStatus.ON_CREATE).assertFail();
expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_CREATE);
promise = null;
promise = await data_Rdb.getRdbStore(context, STORE_CONFIG);
console.info("Get testRdbStore0015 STORE_CONFIG promise.openStatus: " + promise.openStatus)
// expect(promise.openStatus != data_Rdb.OpenStatus.ON_OPEN).assertFail();
expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_OPEN);
promise = null;
promise = await data_Rdb.getRdbStore(context, STORE_CONFIG1);
console.info("Get testRdbStore0015 STORE_CONFIG1 promise.openStatus: " + promise.openStatus)
expect(promise.openStatus).assertEqual(data_Rdb.OpenStatus.ON_OPEN);
}catch(err){
console.info(TAG + "Get testRdbStore0015 fail catch err: " + err)
expect(null).assertFail()
}
await data_Rdb.deleteRdbStore(context, STORE_CONFIG.name)
await data_Rdb.deleteRdbStore(context, STORE_CONFIG1.name)
done();
console.log("Get testRdbStore0015 successfully end.")
})
console.info(TAG + "*************Unit Test End*************");
})}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册