提交 a797f653 编写于 作者: O openharmony_ci 提交者: Gitee

!1026 remove JS context

Merge pull request !1026 from lichenlong1/master
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import dataRdb from '@ohos.data.rdb'; import dataRdb from '@ohos.data.rdb';
import dataAbility from '@ohos.data.dataability'; import dataAbility from '@ohos.data.dataAbility';
import featureAbility from '@ohos.ability.featureAbility';
const TAG = "[RDB_JSKITS _TEST]" const TAG = "[RDB_JSKITS _TEST]"
const CREATE_TABLE_ALL_DATA_TYPE_SQL = "CREATE TABLE IF NOT EXISTS AllDataType " const CREATE_TABLE_ALL_DATA_TYPE_SQL = "CREATE TABLE IF NOT EXISTS AllDataType "
...@@ -31,14 +30,12 @@ const STORE_CONFIG = { ...@@ -31,14 +30,12 @@ const STORE_CONFIG = {
name: "Predicates.db", name: "Predicates.db",
} }
var rdbStore = undefined; var rdbStore = undefined;
var context = undefined;
var DOUBLE_MAX = 9223372036854775807; var DOUBLE_MAX = 9223372036854775807;
describe('dataAbilityPredicatesTest', function () { describe('dataAbilityPredicatesTest', function () {
beforeAll(async function () { beforeAll(async function () {
console.info(TAG + 'beforeAll') console.info(TAG + 'beforeAll')
context = await featureAbility.getContext(); rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
rdbStore = await dataRdb.getRdbStore(context, STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_ALL_DATA_TYPE_SQL, null); await rdbStore.executeSql(CREATE_TABLE_ALL_DATA_TYPE_SQL, null);
await buildAllDataType1(); await buildAllDataType1();
await buildAllDataType2(); await buildAllDataType2();
...@@ -56,7 +53,7 @@ describe('dataAbilityPredicatesTest', function () { ...@@ -56,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(context, "Predicates.db"); await dataRdb.deleteRdbStore("Predicates.db");
}) })
function resultSize(resultSet) { function resultSize(resultSet) {
......
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb'; import dataRdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
const TAG = "[RDB_JSKITS_TEST]" 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)"; 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,7 +22,6 @@ const STORE_CONFIG = { ...@@ -23,7 +22,6 @@ const STORE_CONFIG = {
name: "Delete.db", name: "Delete.db",
} }
var rdbStore = undefined; var rdbStore = undefined;
var context = undefined;
describe('rdbStoreDeleteTest', function () { describe('rdbStoreDeleteTest', function () {
beforeAll(function () { beforeAll(function () {
...@@ -32,8 +30,7 @@ describe('rdbStoreDeleteTest', function () { ...@@ -32,8 +30,7 @@ describe('rdbStoreDeleteTest', function () {
beforeEach(async function () { beforeEach(async function () {
console.info(TAG + 'beforeEach') console.info(TAG + 'beforeEach')
context = await ability_featureAbility.getContext(); rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null); await rdbStore.executeSql(CREATE_TABLE_TEST, null);
}) })
...@@ -41,7 +38,7 @@ describe('rdbStoreDeleteTest', function () { ...@@ -41,7 +38,7 @@ describe('rdbStoreDeleteTest', function () {
console.info(TAG + 'afterEach') console.info(TAG + 'afterEach')
await rdbStore.executeSql("DELETE FROM test"); await rdbStore.executeSql("DELETE FROM test");
rdbStore = null rdbStore = null
await ohos_data_rdb.deleteRdbStore(context, "Delete.db"); await dataRdb.deleteRdbStore("Delete.db");
}) })
afterAll(async function () { afterAll(async function () {
...@@ -86,7 +83,7 @@ describe('rdbStoreDeleteTest', function () { ...@@ -86,7 +83,7 @@ describe('rdbStoreDeleteTest', function () {
} }
//删除 //删除
{ {
let predicates = await new ohos_data_rdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
let deletePromise = rdbStore.delete(predicates) let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => { deletePromise.then(async (ret) => {
expect(3).assertEqual(ret) expect(3).assertEqual(ret)
...@@ -137,7 +134,7 @@ describe('rdbStoreDeleteTest', function () { ...@@ -137,7 +134,7 @@ describe('rdbStoreDeleteTest', function () {
} }
//删除 //删除
{ {
let predicates = await new ohos_data_rdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("name", "zhangsan") predicates.equalTo("name", "zhangsan")
let deletePromise = rdbStore.delete(predicates) let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => { deletePromise.then(async (ret) => {
...@@ -180,14 +177,14 @@ describe('rdbStoreDeleteTest', function () { ...@@ -180,14 +177,14 @@ describe('rdbStoreDeleteTest', function () {
} }
//删除前查询 //删除前查询
{ {
let predicates = await new ohos_data_rdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("age", 28) predicates.equalTo("age", 28)
let resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
expect(1).assertEqual(resultSet.rowCount) expect(1).assertEqual(resultSet.rowCount)
} }
//删除 //删除
{ {
let predicates = await new ohos_data_rdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("age", 28) predicates.equalTo("age", 28)
let deletePromise = rdbStore.delete(predicates) let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => { deletePromise.then(async (ret) => {
...@@ -200,7 +197,7 @@ describe('rdbStoreDeleteTest', function () { ...@@ -200,7 +197,7 @@ describe('rdbStoreDeleteTest', function () {
} }
//删除后查询 //删除后查询
{ {
let predicates = await new ohos_data_rdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("age", 28) predicates.equalTo("age", 28)
let resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
expect(0).assertEqual(resultSet.rowCount) expect(0).assertEqual(resultSet.rowCount)
...@@ -246,7 +243,7 @@ describe('rdbStoreDeleteTest', function () { ...@@ -246,7 +243,7 @@ describe('rdbStoreDeleteTest', function () {
} }
//删除 //删除
{ {
let predicates = await new ohos_data_rdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("aaa id", 1) predicates.equalTo("aaa id", 1)
let deletePromise = rdbStore.delete(predicates) let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => { deletePromise.then(async (ret) => {
...@@ -297,7 +294,7 @@ describe('rdbStoreDeleteTest', function () { ...@@ -297,7 +294,7 @@ describe('rdbStoreDeleteTest', function () {
} }
//删除 //删除
{ {
let predicates = await new ohos_data_rdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
predicates.equalTo("name", "lisi") predicates.equalTo("name", "lisi")
let deletePromise = rdbStore.delete(predicates) let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => { deletePromise.then(async (ret) => {
...@@ -349,7 +346,7 @@ describe('rdbStoreDeleteTest', function () { ...@@ -349,7 +346,7 @@ describe('rdbStoreDeleteTest', function () {
} }
//删除 //删除
{ {
let predicates = await new ohos_data_rdb.RdbPredicates("") let predicates = await new dataRdb.RdbPredicates("")
let deletePromise = rdbStore.delete(predicates) let deletePromise = rdbStore.delete(predicates)
deletePromise.then(async (ret) => { deletePromise.then(async (ret) => {
console.log(TAG + "delete done: " + ret) console.log(TAG + "delete done: " + ret)
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb'; import dataRdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
const TAG = "[RDB_JSKITS_TEST]" 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)"; 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)";
...@@ -25,13 +24,11 @@ const STORE_CONFIG = { ...@@ -25,13 +24,11 @@ const STORE_CONFIG = {
} }
var rdbStore = undefined; var rdbStore = undefined;
var context = undefined;
describe('rdbStoreInsertTest', function () { describe('rdbStoreInsertTest', function () {
beforeAll(async function () { beforeAll(async function () {
console.info(TAG + 'beforeAll') console.info(TAG + 'beforeAll')
context = await ability_featureAbility.getContext(); rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null); await rdbStore.executeSql(CREATE_TABLE_TEST, null);
}) })
...@@ -47,7 +44,7 @@ describe('rdbStoreInsertTest', function () { ...@@ -47,7 +44,7 @@ describe('rdbStoreInsertTest', function () {
afterAll(async function () { afterAll(async function () {
console.info(TAG + 'afterAll') console.info(TAG + 'afterAll')
rdbStore = null rdbStore = null
await ohos_data_rdb.deleteRdbStore(context, "InsertTest.db"); await dataRdb.deleteRdbStore("InsertTest.db");
}) })
console.log(TAG + "*************Unit Test Begin*************"); console.log(TAG + "*************Unit Test Begin*************");
...@@ -88,7 +85,7 @@ describe('rdbStoreInsertTest', function () { ...@@ -88,7 +85,7 @@ describe('rdbStoreInsertTest', function () {
await rdbStore.insert("test", valueBucket) await rdbStore.insert("test", valueBucket)
} }
let predicates = new ohos_data_rdb.RdbPredicates("test"); let predicates = new dataRdb.RdbPredicates("test");
predicates.equalTo("name", "zhangsan") predicates.equalTo("name", "zhangsan")
let resultSet = await rdbStore.query(predicates) let resultSet = await rdbStore.query(predicates)
try { try {
......
...@@ -14,8 +14,7 @@ ...@@ -14,8 +14,7 @@
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb'; import dataRdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
const TAG = "[RDB_JSKITS_TEST]" 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)"; 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 ...@@ -23,11 +22,9 @@ const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIM
const STORE_CONFIG = { const STORE_CONFIG = {
name: "rdbstore.db", name: "rdbstore.db",
} }
var context = undefined;
describe('rdbStoreTest', function () { describe('rdbStoreTest', function () {
beforeAll(async function () { beforeAll(async function () {
console.info(TAG + 'beforeAll') console.info(TAG + 'beforeAll')
context = await ability_featureAbility.getContext();
}) })
beforeEach(function () { beforeEach(function () {
...@@ -51,7 +48,7 @@ describe('rdbStoreTest', function () { ...@@ -51,7 +48,7 @@ describe('rdbStoreTest', function () {
*/ */
it('testRdbStore0001', 0, async function (done) { it('testRdbStore0001', 0, async function (done) {
console.log(TAG + "************* testRdbStore0001 start *************"); 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) => { storePromise.then(async (store) => {
try { try {
await console.log(TAG + "getRdbStore done: " + store); await console.log(TAG + "getRdbStore done: " + store);
...@@ -63,7 +60,7 @@ describe('rdbStoreTest', function () { ...@@ -63,7 +60,7 @@ describe('rdbStoreTest', function () {
}) })
await storePromise await storePromise
storePromise = null storePromise = null
await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db"); await dataRdb.deleteRdbStore("rdbstore.db");
done(); done();
console.log(TAG + "************* testRdbStore0001 end *************"); console.log(TAG + "************* testRdbStore0001 end *************");
}) })
...@@ -75,7 +72,7 @@ describe('rdbStoreTest', function () { ...@@ -75,7 +72,7 @@ describe('rdbStoreTest', function () {
*/ */
it('testRdbStore0002', 0, async function (done) { it('testRdbStore0002', 0, async function (done) {
console.log(TAG + "************* testRdbStore0002 start *************"); 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) => { storePromise.then(async (store) => {
try { try {
await console.log(TAG + "getRdbStore done: " + store); await console.log(TAG + "getRdbStore done: " + store);
...@@ -88,7 +85,7 @@ describe('rdbStoreTest', function () { ...@@ -88,7 +85,7 @@ describe('rdbStoreTest', function () {
}) })
await storePromise await storePromise
storePromise = null storePromise = null
await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db"); await dataRdb.deleteRdbStore("rdbstore.db");
done(); done();
console.log(TAG + "************* testRdbStore0002 end *************"); console.log(TAG + "************* testRdbStore0002 end *************");
}) })
...@@ -104,7 +101,7 @@ describe('rdbStoreTest', function () { ...@@ -104,7 +101,7 @@ describe('rdbStoreTest', function () {
let storeConfig = { let storeConfig = {
name: "/wrong/rdbstore.db", name: "/wrong/rdbstore.db",
} }
let storePromise = ohos_data_rdb.getRdbStore(context, storeConfig, 4); let storePromise = dataRdb.getRdbStore(storeConfig, 4);
storePromise.then(async (ret) => { storePromise.then(async (ret) => {
await console.log(TAG + "getRdbStore done" + ret); await console.log(TAG + "getRdbStore done" + ret);
expect(null).assertFail(); expect(null).assertFail();
...@@ -124,7 +121,7 @@ describe('rdbStoreTest', function () { ...@@ -124,7 +121,7 @@ describe('rdbStoreTest', function () {
it('testRdbStore0004', 0, async function (done) { it('testRdbStore0004', 0, async function (done) {
console.log(TAG + "************* testRdbStore0004 start *************"); 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) => { storePromise.then(async (store) => {
try { try {
await store.executeSql(CREATE_TABLE_TEST); await store.executeSql(CREATE_TABLE_TEST);
...@@ -136,7 +133,7 @@ describe('rdbStoreTest', function () { ...@@ -136,7 +133,7 @@ describe('rdbStoreTest', function () {
}) })
await storePromise await storePromise
storePromise = null storePromise = null
await ohos_data_rdb.deleteRdbStore(context, "rdbstore.db"); await dataRdb.deleteRdbStore("rdbstore.db");
done(); done();
console.log(TAG + "************* testRdbStore0004 end *************"); console.log(TAG + "************* testRdbStore0004 end *************");
}) })
......
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb'; import dataRdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
const TAG = "[RDB_JSKITS_TEST]" 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)"; 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 = { ...@@ -23,13 +22,11 @@ const STORE_CONFIG = {
name: "ExcuteSqlTest.db", name: "ExcuteSqlTest.db",
} }
var rdbStore = undefined; var rdbStore = undefined;
var context = undefined;
describe('rdbStoreInsertTest', function () { describe('rdbStoreInsertTest', function () {
beforeAll(async function () { beforeAll(async function () {
console.info(TAG + 'beforeAll') console.info(TAG + 'beforeAll')
context = await ability_featureAbility.getContext(); rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null); await rdbStore.executeSql(CREATE_TABLE_TEST, null);
}) })
...@@ -45,7 +42,7 @@ describe('rdbStoreInsertTest', function () { ...@@ -45,7 +42,7 @@ describe('rdbStoreInsertTest', function () {
afterAll(async function () { afterAll(async function () {
console.info(TAG + 'afterAll') console.info(TAG + 'afterAll')
rdbStore = null rdbStore = null
await ohos_data_rdb.deleteRdbStore(context, "ExcuteSqlTest.db"); await dataRdb.deleteRdbStore("ExcuteSqlTest.db");
}) })
/** /**
......
...@@ -13,8 +13,7 @@ ...@@ -13,8 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index'
import ohos_data_rdb from '@ohos.data.rdb'; import dataRdb from '@ohos.data.rdb';
import ability_featureAbility from '@ohos.ability.featureAbility';
const TAG = "[RDB_JSKITS_TEST]" 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)"; 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 = { ...@@ -22,13 +21,11 @@ const STORE_CONFIG = {
name: "UpdataTest.db", name: "UpdataTest.db",
} }
var rdbStore = undefined; var rdbStore = undefined;
var context = undefined;
describe('rdbStoreUpdateTest', function () { describe('rdbStoreUpdateTest', function () {
beforeAll(async function () { beforeAll(async function () {
console.info(TAG + 'beforeAll') console.info(TAG + 'beforeAll')
context = await ability_featureAbility.getContext(); rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
rdbStore = await ohos_data_rdb.getRdbStore(context, STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null); await rdbStore.executeSql(CREATE_TABLE_TEST, null);
}) })
...@@ -44,7 +41,7 @@ describe('rdbStoreUpdateTest', function () { ...@@ -44,7 +41,7 @@ describe('rdbStoreUpdateTest', function () {
afterAll(async function () { afterAll(async function () {
console.info(TAG + 'afterAll') console.info(TAG + 'afterAll')
rdbStore = null rdbStore = null
await ohos_data_rdb.deleteRdbStore(context, "UpdataTest.db"); await dataRdb.deleteRdbStore("UpdataTest.db");
}) })
/** /**
...@@ -81,7 +78,7 @@ describe('rdbStoreUpdateTest', function () { ...@@ -81,7 +78,7 @@ describe('rdbStoreUpdateTest', function () {
"salary": 200.5, "salary": 200.5,
"blobType": u8, "blobType": u8,
} }
let predicates = await new ohos_data_rdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
await predicates.equalTo("id", "1") await predicates.equalTo("id", "1")
let updatePromise = rdbStore.update(valueBucket, predicates) let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => { updatePromise.then(async (ret) => {
...@@ -95,7 +92,7 @@ describe('rdbStoreUpdateTest', function () { ...@@ -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) let resultSet = await rdbStore.query(predicates)
expect(true).assertEqual(resultSet.goToFirstRow()) expect(true).assertEqual(resultSet.goToFirstRow())
...@@ -137,7 +134,7 @@ describe('rdbStoreUpdateTest', function () { ...@@ -137,7 +134,7 @@ describe('rdbStoreUpdateTest', function () {
"blobType": u8, "blobType": u8,
} }
{ {
let predicates = new ohos_data_rdb.RdbPredicates("") let predicates = new dataRdb.RdbPredicates("")
let updatePromise = rdbStore.update(valueBucket, predicates) let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => { updatePromise.then(async (ret) => {
await console.log(TAG + "update done: " + ret); await console.log(TAG + "update done: " + ret);
...@@ -148,7 +145,7 @@ describe('rdbStoreUpdateTest', function () { ...@@ -148,7 +145,7 @@ describe('rdbStoreUpdateTest', function () {
} }
{ {
const emptyBucket = {}; const emptyBucket = {};
let predicates = await new ohos_data_rdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
let updatePromise = rdbStore.update(emptyBucket, predicates) let updatePromise = rdbStore.update(emptyBucket, predicates)
updatePromise.then(async (ret) => { updatePromise.then(async (ret) => {
await console.log(TAG + "update done: " + ret); await console.log(TAG + "update done: " + ret);
...@@ -158,7 +155,7 @@ describe('rdbStoreUpdateTest', function () { ...@@ -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") await predicates.equalTo("aaa", "null")
let updatePromise = rdbStore.update(valueBucket, predicates) let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => { updatePromise.then(async (ret) => {
...@@ -191,7 +188,7 @@ describe('rdbStoreUpdateTest', function () { ...@@ -191,7 +188,7 @@ describe('rdbStoreUpdateTest', function () {
"wrongColumn": 100.5, "wrongColumn": 100.5,
} }
{ {
let predicates = new ohos_data_rdb.RdbPredicates("wrongTable") let predicates = new dataRdb.RdbPredicates("wrongTable")
let updatePromise = rdbStore.update(valueBucket, predicates) let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => { updatePromise.then(async (ret) => {
await console.log(TAG + "update done: " + ret); await console.log(TAG + "update done: " + ret);
...@@ -202,7 +199,7 @@ describe('rdbStoreUpdateTest', function () { ...@@ -202,7 +199,7 @@ describe('rdbStoreUpdateTest', function () {
//await updatePromise //await updatePromise
} }
{ {
let predicates = await new ohos_data_rdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
let updatePromise = rdbStore.update(valueBucket, predicates) let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => { updatePromise.then(async (ret) => {
await console.log(TAG + "update done: " + ret); await console.log(TAG + "update done: " + ret);
...@@ -234,7 +231,7 @@ describe('rdbStoreUpdateTest', function () { ...@@ -234,7 +231,7 @@ describe('rdbStoreUpdateTest', function () {
"blobType": u8, "blobType": u8,
} }
{ {
let predicates = await new ohos_data_rdb.RdbPredicates("test") let predicates = await new dataRdb.RdbPredicates("test")
await predicates.equalTo("aaa", "null") await predicates.equalTo("aaa", "null")
let updatePromise = rdbStore.update(valueBucket, predicates) let updatePromise = rdbStore.update(valueBucket, predicates)
updatePromise.then(async (ret) => { updatePromise.then(async (ret) => {
...@@ -247,7 +244,7 @@ describe('rdbStoreUpdateTest', function () { ...@@ -247,7 +244,7 @@ describe('rdbStoreUpdateTest', function () {
} }
{ {
const emptyBucket = {}; 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("name", "zhangsan")
await predicates.equalTo("age", 18) await predicates.equalTo("age", 18)
await predicates.equalTo("null", 100.5) await predicates.equalTo("null", 100.5)
......
...@@ -44,8 +44,8 @@ describe('storageTest', function () { ...@@ -44,8 +44,8 @@ describe('storageTest', function () {
mPref.flushSync(); mPref.flushSync();
await mPref.clear(function (err, ret) { await mPref.clear(function (err, ret) {
expect("defaultvalue").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue")); expect("defaultvalue").assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
done();
}); });
done();
}) })
/** /**
...@@ -57,8 +57,8 @@ describe('storageTest', function () { ...@@ -57,8 +57,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_STRING_ELEMENT, "test"); mPref.putSync(KEY_TEST_STRING_ELEMENT, "test");
await mPref.has(KEY_TEST_STRING_ELEMENT, function (err, ret) { await mPref.has(KEY_TEST_STRING_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret); expect(true).assertEqual(ret);
done();
}) })
done();
}) })
/** /**
...@@ -70,8 +70,8 @@ describe('storageTest', function () { ...@@ -70,8 +70,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_INT_ELEMENT, 1); mPref.putSync(KEY_TEST_INT_ELEMENT, 1);
await mPref.has(KEY_TEST_INT_ELEMENT, function (err, ret) { await mPref.has(KEY_TEST_INT_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret); expect(true).assertEqual(ret);
done();
}) })
done();
}) })
/** /**
...@@ -83,8 +83,8 @@ describe('storageTest', function () { ...@@ -83,8 +83,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 1.1); mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 1.1);
await mPref.has(KEY_TEST_FLOAT_ELEMENT, function (err, ret) { await mPref.has(KEY_TEST_FLOAT_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret); expect(true).assertEqual(ret);
done();
}) })
done();
}) })
/** /**
...@@ -96,8 +96,8 @@ describe('storageTest', function () { ...@@ -96,8 +96,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_LONG_ELEMENT, 0); mPref.putSync(KEY_TEST_LONG_ELEMENT, 0);
await mPref.has(KEY_TEST_LONG_ELEMENT, function (err, ret) { await mPref.has(KEY_TEST_LONG_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret); expect(true).assertEqual(ret);
done();
}) })
done();
}) })
/** /**
...@@ -109,8 +109,8 @@ describe('storageTest', function () { ...@@ -109,8 +109,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, false); mPref.putSync(KEY_TEST_BOOLEAN_ELEMENT, false);
await mPref.has(KEY_TEST_BOOLEAN_ELEMENT, function (err, ret) { await mPref.has(KEY_TEST_BOOLEAN_ELEMENT, function (err, ret) {
expect(true).assertEqual(ret); expect(true).assertEqual(ret);
done();
}) })
done();
}) })
/** /**
...@@ -122,8 +122,8 @@ describe('storageTest', function () { ...@@ -122,8 +122,8 @@ describe('storageTest', function () {
mPref.clearSync(); mPref.clearSync();
await mPref.get(KEY_TEST_STRING_ELEMENT, "defaultValue", function (err, ret) { await mPref.get(KEY_TEST_STRING_ELEMENT, "defaultValue", function (err, ret) {
expect('defaultValue').assertEqual(ret); expect('defaultValue').assertEqual(ret);
done();
}) })
done();
}) })
/** /**
...@@ -136,8 +136,8 @@ describe('storageTest', function () { ...@@ -136,8 +136,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 3.0); mPref.putSync(KEY_TEST_FLOAT_ELEMENT, 3.0);
await mPref.get(KEY_TEST_FLOAT_ELEMENT, 0.0, function (err, ret) { await mPref.get(KEY_TEST_FLOAT_ELEMENT, 0.0, function (err, ret) {
expect(3.0).assertEqual(ret); expect(3.0).assertEqual(ret);
done();
}) })
done();
}) })
/** /**
...@@ -150,8 +150,8 @@ describe('storageTest', function () { ...@@ -150,8 +150,8 @@ describe('storageTest', function () {
mPref.putSync(KEY_TEST_INT_ELEMENT, 3); mPref.putSync(KEY_TEST_INT_ELEMENT, 3);
await mPref.get(KEY_TEST_INT_ELEMENT, 0.0, function (err, ret) { await mPref.get(KEY_TEST_INT_ELEMENT, 0.0, function (err, ret) {
expect(3).assertEqual(ret); expect(3).assertEqual(ret);
done();
}) })
done();
}) })
/** /**
...@@ -165,8 +165,8 @@ describe('storageTest', function () { ...@@ -165,8 +165,8 @@ describe('storageTest', function () {
expect(3).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0)); expect(3).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
await mPref.get(KEY_TEST_LONG_ELEMENT, 0, function (err, ret) { await mPref.get(KEY_TEST_LONG_ELEMENT, 0, function (err, ret) {
expect(3).assertEqual(ret); expect(3).assertEqual(ret);
done();
}); });
done();
}) })
/** /**
...@@ -180,8 +180,8 @@ describe('storageTest', function () { ...@@ -180,8 +180,8 @@ describe('storageTest', function () {
mPref.flushSync(); mPref.flushSync();
await mPref.get(KEY_TEST_STRING_ELEMENT, "defaultvalue", function (err, ret) { await mPref.get(KEY_TEST_STRING_ELEMENT, "defaultvalue", function (err, ret) {
expect('test').assertEqual(ret); expect('test').assertEqual(ret);
done();
}); });
done();
}) })
/** /**
...@@ -195,8 +195,8 @@ describe('storageTest', function () { ...@@ -195,8 +195,8 @@ describe('storageTest', function () {
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false)); expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
mPref.flushSync(); mPref.flushSync();
expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false)); expect(true).assertEqual(mPref.getSync(KEY_TEST_BOOLEAN_ELEMENT, false));
done();
}); });
done();
}) })
/** /**
...@@ -210,8 +210,8 @@ describe('storageTest', function () { ...@@ -210,8 +210,8 @@ describe('storageTest', function () {
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0)); expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
mPref.flushSync(); mPref.flushSync();
expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0)); expect(4.0).assertEqual(mPref.getSync(KEY_TEST_FLOAT_ELEMENT, 0.0));
done();
}); });
done();
}) })
/** /**
...@@ -225,8 +225,8 @@ describe('storageTest', function () { ...@@ -225,8 +225,8 @@ describe('storageTest', function () {
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0)); expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
mPref.flushSync(); mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0)); expect(4).assertEqual(mPref.getSync(KEY_TEST_INT_ELEMENT, 0));
done();
}); });
done();
}) })
/** /**
...@@ -241,8 +241,8 @@ describe('storageTest', function () { ...@@ -241,8 +241,8 @@ describe('storageTest', function () {
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0)); expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
mPref.flushSync(); mPref.flushSync();
expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0)); expect(4).assertEqual(mPref.getSync(KEY_TEST_LONG_ELEMENT, 0));
done();
}); });
done();
}) })
/** /**
...@@ -252,13 +252,11 @@ describe('storageTest', function () { ...@@ -252,13 +252,11 @@ describe('storageTest', function () {
*/ */
it('testPutString0162', 0, async function (done) { it('testPutString0162', 0, async function (done) {
mPref.clearSync(); mPref.clearSync();
await mPref.put(KEY_TEST_STRING_ELEMENT, "abc", function (err, ret) { await mPref.put(KEY_TEST_STRING_ELEMENT, '', function (err, ret) {
mPref.put(KEY_TEST_STRING_ELEMENT, '', function (err, ret) { expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue")); mPref.flushSync();
mPref.flushSync(); expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue"));
expect('').assertEqual(mPref.getSync(KEY_TEST_STRING_ELEMENT, "defaultvalue")); done();
});
}); });
done();
}) })
}) })
\ No newline at end of file
...@@ -110,8 +110,8 @@ describe('storageTest', function () { ...@@ -110,8 +110,8 @@ describe('storageTest', function () {
} }
try { try {
perf.putSync("int", 3); perf.putSync("int", 3);
expect(null).assertFail();
} catch (e) { } catch (e) {
expect(null).assertFail();
} }
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册