提交 5631950c 编写于 作者: Z zhangmaowen

<zhangmaowen@huawei.com>

Signed-off-by: Nzhangmaowen <zhangmaowen@huawei.com>
上级 32f7c922
......@@ -14,8 +14,7 @@
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
import dataRdb from '@ohos.data.rdb';
const TAG = "[RDB_JSKITS_TEST]"
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
......@@ -23,11 +22,9 @@ const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIM
const STORE_CONFIG = {
name: "rdbstore.db",
}
var context = undefined;
describe('rdbStoreTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
context = await ability_featureAbility.getContext();
})
beforeEach(function () {
......@@ -51,7 +48,7 @@ describe('rdbStoreTest', function () {
*/
it('testRdbStore0001', 0, async function (done) {
console.log(TAG + "************* testRdbStore0001 start *************");
let storePromise = ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 1);
storePromise.then(async (store) => {
try {
await console.log(TAG + "getRdbStore done: " + store);
......@@ -63,7 +60,7 @@ describe('rdbStoreTest', function () {
})
await storePromise
storePromise = null
await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db");
await dataRdb.deleteRdbStore("rdbstore.db");
done();
console.log(TAG + "************* testRdbStore0001 end *************");
})
......@@ -75,7 +72,7 @@ describe('rdbStoreTest', function () {
*/
it('testRdbStore0002', 0, async function (done) {
console.log(TAG + "************* testRdbStore0002 start *************");
let storePromise = ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 2);
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 2);
storePromise.then(async (store) => {
try {
await console.log(TAG + "getRdbStore done: " + store);
......@@ -88,7 +85,7 @@ describe('rdbStoreTest', function () {
})
await storePromise
storePromise = null
await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db");
await dataRdb.deleteRdbStore("rdbstore.db");
done();
console.log(TAG + "************* testRdbStore0002 end *************");
})
......@@ -104,7 +101,7 @@ describe('rdbStoreTest', function () {
let storeConfig = {
name: "/wrong/rdbstore.db",
}
let storePromise = ohos_data_rdb.getRdbStore(context, storeConfig, 4);
let storePromise = dataRdb.getRdbStore(storeConfig, 4);
storePromise.then(async (ret) => {
await console.log(TAG + "getRdbStore done" + ret);
expect(null).assertFail();
......@@ -124,7 +121,7 @@ describe('rdbStoreTest', function () {
it('testRdbStore0004', 0, async function (done) {
console.log(TAG + "************* testRdbStore0004 start *************");
let storePromise = ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 6);
let storePromise = dataRdb.getRdbStore(STORE_CONFIG, 6);
storePromise.then(async (store) => {
try {
await store.executeSql(CREATE_TABLE_TEST);
......@@ -136,7 +133,7 @@ describe('rdbStoreTest', function () {
})
await storePromise
storePromise = null
await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db");
await dataRdb.deleteRdbStore("rdbstore.db");
done();
console.log(TAG + "************* testRdbStore0004 end *************");
})
......
......@@ -13,8 +13,7 @@
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
import dataRdb from '@ohos.data.rdb';
const TAG = "[RDB_JSKITS_TEST]"
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
......@@ -23,13 +22,11 @@ const STORE_CONFIG = {
name: "ExcuteSqlTest.db",
}
var rdbStore = undefined;
var context = undefined;
describe('rdbStoreInsertTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
})
......@@ -45,7 +42,7 @@ describe('rdbStoreInsertTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await ohos_data_rdb.deleteRdbStore(context, "ExcuteSqlTest.db");
await dataRdb.deleteRdbStore("ExcuteSqlTest.db");
})
/**
......
......@@ -13,8 +13,7 @@
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
import dataRdb from '@ohos.data.rdb';
const TAG = "[RDB_JSKITS_TEST]"
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT UNIQUE, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)";
......@@ -22,13 +21,11 @@ const STORE_CONFIG = {
name: "UpdataTest.db",
}
var rdbStore = undefined;
var context = undefined;
describe('rdbStoreUpdateTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
})
......@@ -44,7 +41,7 @@ describe('rdbStoreUpdateTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await ohos_data_rdb.deleteRdbStore(context, "UpdataTest.db");
await dataRdb.deleteRdbStore("UpdataTest.db");
})
/**
......@@ -81,7 +78,7 @@ describe('rdbStoreUpdateTest', function () {
"salary": 200.5,
"blobType": u8,
}
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
await predicates.equalTo("id", "1")
let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => {
......@@ -95,7 +92,7 @@ describe('rdbStoreUpdateTest', function () {
}
//查询
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
let resultSet = await rdbStore.query(predicates)
expect(true).assertEqual(resultSet.goToFirstRow())
......@@ -137,7 +134,7 @@ describe('rdbStoreUpdateTest', function () {
"blobType": u8,
}
{
let predicates = new ohos_data_rdb.RdbPredicates("")
let predicates = new dataRdb.RdbPredicates("")
let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => {
await console.log(TAG + "update done: " + ret);
......@@ -148,7 +145,7 @@ describe('rdbStoreUpdateTest', function () {
}
{
const emptyBucket = {};
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
let updatePromise = rdbStore.update(emptyBucket, predicates)
updatePromise.then(async (ret) => {
await console.log(TAG + "update done: " + ret);
......@@ -158,7 +155,7 @@ describe('rdbStoreUpdateTest', function () {
})
}
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
await predicates.equalTo("aaa", "null")
let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => {
......@@ -191,7 +188,7 @@ describe('rdbStoreUpdateTest', function () {
"wrongColumn": 100.5,
}
{
let predicates = new ohos_data_rdb.RdbPredicates("wrongTable")
let predicates = new dataRdb.RdbPredicates("wrongTable")
let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => {
await console.log(TAG + "update done: " + ret);
......@@ -202,7 +199,7 @@ describe('rdbStoreUpdateTest', function () {
//await updatePromise
}
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => {
await console.log(TAG + "update done: " + ret);
......@@ -234,7 +231,7 @@ describe('rdbStoreUpdateTest', function () {
"blobType": u8,
}
{
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
await predicates.equalTo("aaa", "null")
let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => {
......@@ -247,7 +244,7 @@ describe('rdbStoreUpdateTest', function () {
}
{
const emptyBucket = {};
let predicates = await new ohos_data_rdb.RdbPredicates("test")
let predicates = await new dataRdb.RdbPredicates("test")
await predicates.equalTo("name", "zhangsan")
await predicates.equalTo("age", 18)
await predicates.equalTo("null", 100.5)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册