提交 e6fc69f0 编写于 作者: S smagicyun

add parameter context to getRdbstore and deleteRdbstore

Signed-off-by: Nsmagicyun <yanghongliang.yang@huawei.com>
上级 16d5135a
......@@ -15,6 +15,7 @@
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb';
import data_dataability from '@ohos.data.dataability';
import ability_featureAbility from '@ohos.ability.featureAbility';
const TAG = "[RDB_JSKITS _TEST]"
const CREATE_TABLE_ALL_DATA_TYPE_SQL = "CREATE TABLE IF NOT EXISTS AllDataType "
......@@ -30,11 +31,13 @@ const STORE_CONFIG = {
name: "Predicates.db",
}
var rdbStore = undefined;
var context = undefined;
describe('dataAbilityPredicatesTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
rdbStore = await ohos_data_rdb.getRdbStore(STORE_CONFIG, 1);
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_ALL_DATA_TYPE_SQL, null);
await buildAllDataType1();
await buildAllDataType2();
......@@ -52,7 +55,7 @@ describe('dataAbilityPredicatesTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await ohos_data_rdb.deleteRdbStore("Predicates.db");
await ohos_data_rdb.deleteRdbStore(context, "Predicates.db");
})
function resultSize(resultSet) {
......
......@@ -14,6 +14,7 @@
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import data_rdb from '@ohos.data.rdb'
import ability_featureAbility from '@ohos.ability.featureAbility';
const TAG = "[RDB_JSKITS_TEST]"
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "data1 text," + "data2 long, " + "data3 double," + "data4 blob)";
......@@ -22,11 +23,13 @@ const STORE_CONFIG = {
name: "Resultset.db",
}
var rdbStore = undefined;
var context = undefined;
describe('rdbResultSetTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
rdbStore = await data_rdb.getRdbStore(STORE_CONFIG, 1);
context = await ability_featureAbility.getContext();
rdbStore = await data_rdb.getRdbStore(context, STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
await createTest();
})
......@@ -42,7 +45,7 @@ describe('rdbResultSetTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await data_rdb.deleteRdbStore("Resultset.db");
await data_rdb.deleteRdbStore(context, "Resultset.db");
})
//插入数据
async function createTest() {
......
......@@ -14,6 +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';
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)";
......@@ -22,6 +23,7 @@ const STORE_CONFIG = {
name: "Delete.db",
}
var rdbStore = undefined;
var context = undefined;
describe('rdbStoreDeleteTest', function () {
beforeAll(function () {
......@@ -30,7 +32,8 @@ describe('rdbStoreDeleteTest', function () {
beforeEach(async function () {
console.info(TAG + 'beforeEach')
rdbStore = await ohos_data_rdb.getRdbStore(STORE_CONFIG, 1);
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
})
......@@ -38,7 +41,7 @@ describe('rdbStoreDeleteTest', function () {
console.info(TAG + 'afterEach')
await rdbStore.executeSql("DELETE FROM test");
rdbStore = null
await ohos_data_rdb.deleteRdbStore("Delete.db");
await ohos_data_rdb.deleteRdbStore(context, "Delete.db");
})
afterAll(async function () {
......
......@@ -15,6 +15,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';
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)";
......@@ -24,11 +25,13 @@ const STORE_CONFIG = {
}
var rdbStore = undefined;
var context = undefined;
describe('rdbStoreInsertTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
rdbStore = await ohos_data_rdb.getRdbStore(STORE_CONFIG, 1);
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
})
......@@ -44,7 +47,7 @@ describe('rdbStoreInsertTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await ohos_data_rdb.deleteRdbStore("InsertTest.db");
await ohos_data_rdb.deleteRdbStore(context, "InsertTest.db");
})
console.log(TAG + "*************Unit Test Begin*************");
......
......@@ -14,6 +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';
const TAG = "[RDB_JSKITS _TEST]"
const CREATE_TABLE_ALL_DATA_TYPE_SQL = "CREATE TABLE IF NOT EXISTS AllDataType "
......@@ -29,11 +30,13 @@ const STORE_CONFIG = {
name: "Predicates.db",
}
var rdbStore = undefined;
var context = undefined;
describe('rdbPredicatesTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
rdbStore = await ohos_data_rdb.getRdbStore(STORE_CONFIG, 1);
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_ALL_DATA_TYPE_SQL, null);
await buildAllDataType1();
await buildAllDataType2();
......@@ -51,7 +54,7 @@ describe('rdbPredicatesTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await ohos_data_rdb.deleteRdbStore("Predicates.db");
await ohos_data_rdb.deleteRdbStore(context, "Predicates.db");
})
function resultSize(resultSet) {
......
......@@ -15,6 +15,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';
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)";
......@@ -22,10 +23,11 @@ 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 () {
......@@ -49,7 +51,7 @@ describe('rdbStoreTest', function () {
*/
it('testRdbStore0001', 0, async function (done) {
console.log(TAG + "************* testRdbStore0001 start *************");
let storePromise = ohos_data_rdb.getRdbStore(STORE_CONFIG, 1);
let storePromise = ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
storePromise.then(async (store) => {
try {
await console.log(TAG + "getRdbStore done: " + store);
......@@ -61,7 +63,7 @@ describe('rdbStoreTest', function () {
})
await storePromise
storePromise = null
await ohos_data_rdb.deleteRdbStore("rdbstore.db");
await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db");
done();
console.log(TAG + "************* testRdbStore0001 end *************");
})
......@@ -73,7 +75,7 @@ describe('rdbStoreTest', function () {
*/
it('testRdbStore0002', 0, async function (done) {
console.log(TAG + "************* testRdbStore0002 start *************");
let storePromise = ohos_data_rdb.getRdbStore(STORE_CONFIG, 2);
let storePromise = ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 2);
storePromise.then(async (store) => {
try {
await console.log(TAG + "getRdbStore done: " + store);
......@@ -86,7 +88,7 @@ describe('rdbStoreTest', function () {
})
await storePromise
storePromise = null
await ohos_data_rdb.deleteRdbStore("rdbstore.db");
await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db");
done();
console.log(TAG + "************* testRdbStore0002 end *************");
})
......@@ -102,7 +104,7 @@ describe('rdbStoreTest', function () {
let storeConfig = {
name: "/wrong/rdbstore.db",
}
let storePromise = ohos_data_rdb.getRdbStore(storeConfig, 4);
let storePromise = ohos_data_rdb.getRdbStore(context, storeConfig, 4);
storePromise.then(async (ret) => {
await console.log(TAG + "getRdbStore done" + ret);
expect(null).assertFail();
......@@ -122,7 +124,7 @@ describe('rdbStoreTest', function () {
it('testRdbStore0004', 0, async function (done) {
console.log(TAG + "************* testRdbStore0004 start *************");
let storePromise = ohos_data_rdb.getRdbStore(STORE_CONFIG, 6);
let storePromise = ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 6);
storePromise.then(async (store) => {
try {
await store.executeSql(CREATE_TABLE_TEST);
......@@ -134,7 +136,7 @@ describe('rdbStoreTest', function () {
})
await storePromise
storePromise = null
await ohos_data_rdb.deleteRdbStore("rdbstore.db");
await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db");
done();
console.log(TAG + "************* testRdbStore0004 end *************");
})
......
......@@ -14,6 +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';
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)";
......@@ -22,11 +23,13 @@ const STORE_CONFIG = {
name: "ExcuteSqlTest.db",
}
var rdbStore = undefined;
var context = undefined;
describe('rdbStoreInsertTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
rdbStore = await ohos_data_rdb.getRdbStore(STORE_CONFIG, 1);
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
})
......@@ -42,7 +45,7 @@ describe('rdbStoreInsertTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await ohos_data_rdb.deleteRdbStore("ExcuteSqlTest.db");
await ohos_data_rdb.deleteRdbStore(context, "ExcuteSqlTest.db");
})
/**
......
......@@ -14,6 +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';
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)";
......@@ -21,11 +22,13 @@ const STORE_CONFIG = {
name: "UpdataTest.db",
}
var rdbStore = undefined;
var context = undefined;
describe('rdbStoreUpdateTest', function () {
beforeAll(async function () {
console.info(TAG + 'beforeAll')
rdbStore = await ohos_data_rdb.getRdbStore(STORE_CONFIG, 1);
context = await ability_featureAbility.getContext();
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null);
})
......@@ -41,7 +44,7 @@ describe('rdbStoreUpdateTest', function () {
afterAll(async function () {
console.info(TAG + 'afterAll')
rdbStore = null
await ohos_data_rdb.deleteRdbStore("UpdataTest.db");
await ohos_data_rdb.deleteRdbStore(context, "UpdataTest.db");
})
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册