未验证 提交 6582f3c2 编写于 作者: O openharmony_ci 提交者: Gitee

!9860 distributeddatamgr

Merge pull request !9860 from lixinyi1094590959/master
...@@ -89,7 +89,7 @@ export default function preferencesCallBackTest() { ...@@ -89,7 +89,7 @@ export default function preferencesCallBackTest() {
}); });
} catch (err) { } catch (err) {
console.info("testPreferencesGetPreferences002 fail: " + err.message + "code: " + err.code); console.info("testPreferencesGetPreferences002 fail: " + err.message + "code: " + err.code);
expect(err.code === "401" && err.message === "Parameter error. The type of 'name' must be a without path non empty string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -145,7 +145,7 @@ export default function preferencesCallBackTest() { ...@@ -145,7 +145,7 @@ export default function preferencesCallBackTest() {
}); });
} catch (err) { } catch (err) {
console.info("testPreferencesDeletePreferences001 fail: " + err.message + "code: " + err.code); console.info("testPreferencesDeletePreferences001 fail: " + err.message + "code: " + err.code);
expect(err.code === "401" && err.message === "Parameter error. The type of 'name' must be a without path non empty string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
} }
...@@ -239,7 +239,7 @@ export default function preferencesCallBackTest() { ...@@ -239,7 +239,7 @@ export default function preferencesCallBackTest() {
}); });
} catch (err) { } catch (err) {
console.info("testRemovePreferencesFromCache001 fail: " + err.message + "code: " + err.code); console.info("testRemovePreferencesFromCache001 fail: " + err.message + "code: " + err.code);
expect(err.code === "401" && err.message === "Parameter error. The type of 'name' must be a without path non empty string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
} }
......
...@@ -98,7 +98,7 @@ export default function preferencesCallbackWithErrorTest() { ...@@ -98,7 +98,7 @@ export default function preferencesCallbackWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. Need 2 or 3 parameters!").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
console.log("testMpreferencesGet0000 end."); console.log("testMpreferencesGet0000 end.");
} }
...@@ -126,7 +126,7 @@ export default function preferencesCallbackWithErrorTest() { ...@@ -126,7 +126,7 @@ export default function preferencesCallbackWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. The type of 'value' must be string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -203,7 +203,7 @@ export default function preferencesCallbackWithErrorTest() { ...@@ -203,7 +203,7 @@ export default function preferencesCallbackWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. The type of 'value' must be string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
console.log("testMpreferencesHas0001 end."); console.log("testMpreferencesHas0001 end.");
} }
...@@ -252,7 +252,7 @@ export default function preferencesCallbackWithErrorTest() { ...@@ -252,7 +252,7 @@ export default function preferencesCallbackWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. Need 2 or 3 parameters!").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
console.log("testMpreferencesPut0001 end."); console.log("testMpreferencesPut0001 end.");
} }
...@@ -339,7 +339,7 @@ export default function preferencesCallbackWithErrorTest() { ...@@ -339,7 +339,7 @@ export default function preferencesCallbackWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. The type of 'value' must be string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -367,7 +367,7 @@ export default function preferencesCallbackWithErrorTest() { ...@@ -367,7 +367,7 @@ export default function preferencesCallbackWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. The type of 'value' must be ValueType.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -389,7 +389,7 @@ export default function preferencesCallbackWithErrorTest() { ...@@ -389,7 +389,7 @@ export default function preferencesCallbackWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. The type of 'value' must be string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
console.log("testMpreferencesDelete0001 end."); console.log("testMpreferencesDelete0001 end.");
} }
......
...@@ -58,7 +58,7 @@ export default function preferencesIgnoreTest() { ...@@ -58,7 +58,7 @@ export default function preferencesIgnoreTest() {
}); });
} catch (err) { } catch (err) {
console.info("testPreferencesGetPreferences001 fail: " + err.message + "code: " + err.code); console.info("testPreferencesGetPreferences001 fail: " + err.message + "code: " + err.code);
expect(err.code === "401" && err.message == "Parameter error. The type of 'name' must be a without path non empty string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -90,7 +90,7 @@ export default function preferencesIgnoreTest() { ...@@ -90,7 +90,7 @@ export default function preferencesIgnoreTest() {
}); });
} catch (err) { } catch (err) {
console.info("testPreferencesDeletePreferences002 fail: " + err.message + "code: " + err.code); console.info("testPreferencesDeletePreferences002 fail: " + err.message + "code: " + err.code);
expect(err.code === "401" && err.message === "Parameter error. The type of 'name' must be a without path non empty string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
} }
...@@ -124,7 +124,7 @@ export default function preferencesIgnoreTest() { ...@@ -124,7 +124,7 @@ export default function preferencesIgnoreTest() {
}); });
} catch (err) { } catch (err) {
console.info("testRemovePreferencesFromCache002 fail: " + err.message + "code: " + err.code); console.info("testRemovePreferencesFromCache002 fail: " + err.message + "code: " + err.code);
expect(err.code === "401" && err.message === "Parameter error. The type of 'name' must be a without path non empty string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
} }
...@@ -145,7 +145,7 @@ export default function preferencesIgnoreTest() { ...@@ -145,7 +145,7 @@ export default function preferencesIgnoreTest() {
await dataPreferences.getPreferences(context, -1); await dataPreferences.getPreferences(context, -1);
} catch (err) { } catch (err) {
console.info("testGetPreferencesHelper0003 fail: " + err.message + "code: " + err.code); console.info("testGetPreferencesHelper0003 fail: " + err.message + "code: " + err.code);
expect(err.code === "401" && err.message === "Parameter error. The type of 'name' must be a without path non empty string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -164,7 +164,7 @@ export default function preferencesIgnoreTest() { ...@@ -164,7 +164,7 @@ export default function preferencesIgnoreTest() {
await dataPreferences.getPreferences(context); await dataPreferences.getPreferences(context);
} catch (err) { } catch (err) {
console.info("testGetPreferencesHelper0004 fail: " + err.message + "code: " + err.code); console.info("testGetPreferencesHelper0004 fail: " + err.message + "code: " + err.code);
expect(err.code === "401" && err.message === "Parameter error. Need 2 or 3 parameters!").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -184,7 +184,7 @@ export default function preferencesIgnoreTest() { ...@@ -184,7 +184,7 @@ export default function preferencesIgnoreTest() {
await dataPreferences.removePreferencesFromCache(context); await dataPreferences.removePreferencesFromCache(context);
} catch (err) { } catch (err) {
console.info("testRemovePreferencesFromCacheHelper0002 fail: " + err.message + "code: " + err.code); console.info("testRemovePreferencesFromCacheHelper0002 fail: " + err.message + "code: " + err.code);
expect(err.code === "401" && err.message === "Parameter error. Need 2 or 3 parameters!").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -204,7 +204,7 @@ export default function preferencesIgnoreTest() { ...@@ -204,7 +204,7 @@ export default function preferencesIgnoreTest() {
await dataPreferences.removePreferencesFromCache(context, -1); await dataPreferences.removePreferencesFromCache(context, -1);
} catch (err) { } catch (err) {
console.info("testRemovePreferencesFromCacheHelper0003 fail: " + err.message + "code: " + err.code); console.info("testRemovePreferencesFromCacheHelper0003 fail: " + err.message + "code: " + err.code);
expect(err.code === "401" && err.message === "Parameter error. The type of 'name' must be a without path non empty string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -224,7 +224,7 @@ export default function preferencesIgnoreTest() { ...@@ -224,7 +224,7 @@ export default function preferencesIgnoreTest() {
await dataPreferences.deletePreferences(context); await dataPreferences.deletePreferences(context);
} catch (err) { } catch (err) {
console.info("testPreferencesDeleteHelper0002 fail: " + err.message + "code: " + err.code); console.info("testPreferencesDeleteHelper0002 fail: " + err.message + "code: " + err.code);
expect(err.code === "401" && err.message === "Parameter error. Need 2 or 3 parameters!").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -244,7 +244,7 @@ export default function preferencesIgnoreTest() { ...@@ -244,7 +244,7 @@ export default function preferencesIgnoreTest() {
await dataPreferences.deletePreferences(context, -1); await dataPreferences.deletePreferences(context, -1);
} catch (err) { } catch (err) {
console.info("testPreferencesDeleteHelper0003 fail: " + err.message + "code: " + err.code); console.info("testPreferencesDeleteHelper0003 fail: " + err.message + "code: " + err.code);
expect(err.code === "401" && err.message === "Parameter error. The type of 'name' must be a without path non empty string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
......
...@@ -127,7 +127,7 @@ export default function preferencesPromiseWithErrorTest() { ...@@ -127,7 +127,7 @@ export default function preferencesPromiseWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. Need 2 or 3 parameters!").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
console.log("testMpreferencesGetPromise0001 end."); console.log("testMpreferencesGetPromise0001 end.");
} }
...@@ -157,7 +157,7 @@ export default function preferencesPromiseWithErrorTest() { ...@@ -157,7 +157,7 @@ export default function preferencesPromiseWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. The type of 'value' must be string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -205,7 +205,7 @@ export default function preferencesPromiseWithErrorTest() { ...@@ -205,7 +205,7 @@ export default function preferencesPromiseWithErrorTest() {
mPreference.getSync(1233); mPreference.getSync(1233);
} catch (err) { } catch (err) {
console.log("trycatch1 err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch1 err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. Need 2 parameters!").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
console.log("testMpreferencesGetSyncWithError0001 end."); console.log("testMpreferencesGetSyncWithError0001 end.");
} }
...@@ -226,7 +226,7 @@ export default function preferencesPromiseWithErrorTest() { ...@@ -226,7 +226,7 @@ export default function preferencesPromiseWithErrorTest() {
mPreference.getSync(-1, KEY_TEST_INT_ELEMENT); mPreference.getSync(-1, KEY_TEST_INT_ELEMENT);
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. The type of 'value' must be string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -303,7 +303,7 @@ export default function preferencesPromiseWithErrorTest() { ...@@ -303,7 +303,7 @@ export default function preferencesPromiseWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. The type of 'value' must be string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
console.log("testMpreferencesHasPromise0001 end."); console.log("testMpreferencesHasPromise0001 end.");
} }
...@@ -358,7 +358,7 @@ export default function preferencesPromiseWithErrorTest() { ...@@ -358,7 +358,7 @@ export default function preferencesPromiseWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. Need 2 or 3 parameters!").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
console.log("testMpreferencesPutPromise0001 end."); console.log("testMpreferencesPutPromise0001 end.");
} }
...@@ -451,7 +451,7 @@ export default function preferencesPromiseWithErrorTest() { ...@@ -451,7 +451,7 @@ export default function preferencesPromiseWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. The type of 'value' must be string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -480,7 +480,7 @@ export default function preferencesPromiseWithErrorTest() { ...@@ -480,7 +480,7 @@ export default function preferencesPromiseWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. The type of 'value' must be ValueType.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -499,7 +499,7 @@ export default function preferencesPromiseWithErrorTest() { ...@@ -499,7 +499,7 @@ export default function preferencesPromiseWithErrorTest() {
mPreference.putSync(1233); mPreference.putSync(1233);
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. Need 2 parameters!").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
console.log("testMpreferencesPutSyncWithError0001 end."); console.log("testMpreferencesPutSyncWithError0001 end.");
} }
...@@ -565,7 +565,7 @@ export default function preferencesPromiseWithErrorTest() { ...@@ -565,7 +565,7 @@ export default function preferencesPromiseWithErrorTest() {
mPreference.putSync(-1, 123); mPreference.putSync(-1, 123);
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. The type of 'value' must be string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -584,7 +584,7 @@ export default function preferencesPromiseWithErrorTest() { ...@@ -584,7 +584,7 @@ export default function preferencesPromiseWithErrorTest() {
mPreference.putSync(KEY_TEST_STRING_ELEMENT, null); mPreference.putSync(KEY_TEST_STRING_ELEMENT, null);
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. The type of 'value' must be ValueType.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
} }
}); });
...@@ -611,7 +611,7 @@ export default function preferencesPromiseWithErrorTest() { ...@@ -611,7 +611,7 @@ export default function preferencesPromiseWithErrorTest() {
}); });
} catch (err) { } catch (err) {
console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message); console.log("trycatch err =" + err + ", code =" + err.code + ", message =" + err.message);
expect(err.code === "401" && err.message === "Parameter error. The type of 'value' must be string.").assertTrue(); expect(err.code === "401").assertTrue();
done(); done();
console.log("testMpreferencesDeletePromise0001 end."); console.log("testMpreferencesDeletePromise0001 end.");
} }
......
...@@ -36,7 +36,7 @@ describe('rdbstoreInsertTest', function () { ...@@ -36,7 +36,7 @@ describe('rdbstoreInsertTest', function () {
console.info(TAG + 'beforeAll') console.info(TAG + 'beforeAll')
rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1); rdbStore = await dataRdb.getRdbStore(STORE_CONFIG, 1);
await rdbStore.executeSql(CREATE_TABLE_TEST, null) await rdbStore.executeSql(CREATE_TABLE_TEST, null)
await rdbStore.executeSql(CREATE_TABLE_BATCHINSERT_TEST, null);
}) })
beforeEach(async function () { beforeEach(async function () {
......
...@@ -55,7 +55,7 @@ describe('rdbStorePredicatesJoinTest', function () { ...@@ -55,7 +55,7 @@ describe('rdbStorePredicatesJoinTest', function () {
afterEach(async function () { afterEach(async function () {
console.info(TAG + 'afterEach') console.info(TAG + 'afterEach')
await dataRdb.deleteRdbStore("InsertTest.db"); await dataRdb.deleteRdbStore("RdbJoinTest.db");
rdbStore = null rdbStore = null
console.info(TAG + 'afterEach end') console.info(TAG + 'afterEach end')
}) })
......
...@@ -19,6 +19,7 @@ import abilityFeatureAbility from '@ohos.ability.featureAbility'; ...@@ -19,6 +19,7 @@ import abilityFeatureAbility from '@ohos.ability.featureAbility';
var context = abilityFeatureAbility.getContext(); var context = abilityFeatureAbility.getContext();
var contextApplication = context.getApplicationContext() var contextApplication = context.getApplicationContext()
var rdbStore = undefined;
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)";
......
...@@ -39,7 +39,7 @@ describe('relationalStoreInsertTest', function () { ...@@ -39,7 +39,7 @@ describe('relationalStoreInsertTest', function () {
console.info(TAG + 'beforeAll') console.info(TAG + 'beforeAll')
rdbStore = await data_Rdb.getRdbStore(context, STORE_CONFIG); rdbStore = await data_Rdb.getRdbStore(context, STORE_CONFIG);
await rdbStore.executeSql(CREATE_TABLE_TEST, null) await rdbStore.executeSql(CREATE_TABLE_TEST, null)
await rdbStore.executeSql(CREATE_TABLE_BATCHINSERT_TEST, null);
}) })
beforeEach(async function () { beforeEach(async function () {
......
...@@ -60,7 +60,7 @@ describe('relationalStorePredicatesJoinTest', function () { ...@@ -60,7 +60,7 @@ describe('relationalStorePredicatesJoinTest', function () {
afterEach(async function () { afterEach(async function () {
console.info(TAG + 'afterEach') console.info(TAG + 'afterEach')
await data_Rdb.deleteRdbStore(context, "InsertTest.db"); await data_Rdb.deleteRdbStore(context, "RdbJoinTest.db");
rdbStore = null rdbStore = null
console.info(TAG + 'afterEach end') console.info(TAG + 'afterEach end')
}) })
......
...@@ -19,12 +19,13 @@ import ability_featureAbility from '@ohos.ability.featureAbility'; ...@@ -19,12 +19,13 @@ import ability_featureAbility from '@ohos.ability.featureAbility';
const TAG = "[RelationalStore_JSKITS_TEST]" const TAG = "[RelationalStore_JSKITS_TEST]"
const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " 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)" + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"
const STORE_CONFIG = { const STORE_CONFIG = {
name: "Query.db", name: "Query.db",
securityLevel: data_Rdb.SecurityLevel.S1 securityLevel: data_Rdb.SecurityLevel.S1
} }
const TEST_BUNDLE_NAME="ohos.acts.relationalstorejstest" const TEST_BUNDLE_NAME="ohos.acts.relationalstorejstest"
const TEST_STORE_ID="storeId";
var kvManager = null var kvManager = null
var kvStore = null var kvStore = null
...@@ -63,11 +64,11 @@ async function CreatRdbStore(context, STORE_CONFIG) { ...@@ -63,11 +64,11 @@ async function CreatRdbStore(context, STORE_CONFIG) {
} }
await RdbStore.insert("test", valueBucket) await RdbStore.insert("test", valueBucket)
} }
return RdbStore
} }
async function getLocalDeviceId(){ async function getLocalDeviceId(){
} }
export default function relationalStoreQueryTest(){ export default function relationalStoreQueryTest(){
describe("relationalStoreQueryTest", function() { describe("relationalStoreQueryTest", function() {
...@@ -80,7 +81,7 @@ export default function relationalStoreQueryTest(){ ...@@ -80,7 +81,7 @@ export default function relationalStoreQueryTest(){
context:context context:context
} }
} }
const options = { const options = {
createIfMissing : true, createIfMissing : true,
encrypt : false, encrypt : false,
...@@ -90,44 +91,44 @@ export default function relationalStoreQueryTest(){ ...@@ -90,44 +91,44 @@ export default function relationalStoreQueryTest(){
schema : '', schema : '',
securityLevel : factory.SecurityLevel.S2, securityLevel : factory.SecurityLevel.S2,
} }
console.info('getLocalDeviceId config:'+ JSON.stringify(config)); console.info('getLocalDeviceId config:'+ JSON.stringify(config));
await factory.createKVManager(config).then((manager) => { await factory.createKVManager(config).then((manager) => {
kvManager = manager; kvManager = manager;
console.info('getLocalDeviceId createKVManager success'); console.info('getLocalDeviceId createKVManager success');
}).catch((err) => { }).catch((err) => {
console.info('getLocalDeviceId createKVManager err ' + err); console.info('getLocalDeviceId createKVManager err ' + err);
}); });
await kvManager.getKVStore(TEST_STORE_ID, options).then((store) => { await kvManager.getKVStore(TEST_STORE_ID, options).then((store) => {
kvStore = store; kvStore = store;
console.info('getLocalDeviceId getKVStore for getDeviceId success'); console.info('getLocalDeviceId getKVStore for getDeviceId success');
}).catch((err) => { }).catch((err) => {
console.info('getLocalDeviceId getKVStore err ' + err); console.info('getLocalDeviceId getKVStore err ' + err);
}); });
var getDeviceId = new Promise((resolve, reject) => { var getDeviceId = new Promise((resolve, reject) => {
kvStore.on('dataChange', 0, function (data) { kvStore.on('dataChange', 0, function (data) {
console.info('getLocalDeviceId on data change: ' + JSON.stringify(data)); console.info('getLocalDeviceId on data change: ' + JSON.stringify(data));
resolve(data.deviceId); resolve(data.deviceId);
});
kvStore.put("getDeviceId", "byPut").then((data) => {
console.info('getLocalDeviceId put success');
expect(data == undefined).assertTrue();
});
setTimeout(() => {
reject(new Error('not resolved in 2 second, reject it.'))
}, 2000);
}); });
await getDeviceId.then(function(deviceId) { kvStore.put("getDeviceId", "byPut").then((data) => {
console.info('getLocalDeviceId getDeviceId ' + JSON.stringify(deviceId)); console.info('getLocalDeviceId put success');
localDeviceId = deviceId; expect(data == undefined).assertTrue();
}).catch((error) => {
console.info('getLocalDeviceId can NOT getDeviceId, fail: ' + error);
expect(null).assertFail();
}); });
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore); setTimeout(() => {
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID); reject(new Error('not resolved in 2 second, reject it.'))
kvStore = null; }, 2000);
console.info('getLocalDeviceId end'); });
await getDeviceId.then(function(deviceId) {
console.info('getLocalDeviceId getDeviceId ' + JSON.stringify(deviceId));
localDeviceId = deviceId;
}).catch((error) => {
console.info('getLocalDeviceId can NOT getDeviceId, fail: ' + error);
expect(null).assertFail();
});
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore);
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID);
kvStore = null;
console.info('getLocalDeviceId end');
getLocalDeviceId() getLocalDeviceId()
console.info(TAG + 'beforeAll') console.info(TAG + 'beforeAll')
done(); done();
...@@ -135,7 +136,7 @@ export default function relationalStoreQueryTest(){ ...@@ -135,7 +136,7 @@ export default function relationalStoreQueryTest(){
beforeEach(async function () { beforeEach(async function () {
console.info(TAG + 'beforeEach') console.info(TAG + 'beforeEach')
rdbStore = await CreatRdbStore(context, STORE_CONFIG) rdbStore = await CreatRdbStore(context, STORE_CONFIG)
}) })
...@@ -149,31 +150,38 @@ export default function relationalStoreQueryTest(){ ...@@ -149,31 +150,38 @@ export default function relationalStoreQueryTest(){
}) })
/** /**
* @tc.name RelationalStore remotequery test * @tc.name RelationalStore remotequery test
* @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0010 * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0010
* @tc.desc RelationalStore remotequery function test * @tc.desc RelationalStore remotequery function test
*/ */
it('RdbRemoteQueryPromiseTest0010', 0, async function (done){
it('RdbRemoteQueryPromiseTest0010', 0, async function (done){
console.info(TAG + "RdbRemoteQueryPromiseTest0010 start") console.info(TAG + "RdbRemoteQueryPromiseTest0010 start")
let errInfo = undefined
let predicates = new data_Rdb.RdbPredicates("test"); let predicates = new data_Rdb.RdbPredicates("test");
predicates.equalTo("name", "zhangsan") predicates.equalTo("name", "zhangsan")
try{ try{
rdbStore.remoteQuery(localDeviceId,"test",predicates,["name","age","salary"]) await rdbStore.remoteQuery(localDeviceId,"test",predicates,["name","age","salary"]).then((resultSet) => {
console.info(TAG + "Remote query success")
expect().assertFail();
}).catch((err) => {
console.info(TAG + "Remote query error" + err)
expect().assertFail();
})
}catch(err){ }catch(err){
errInfo = err console.info(TAG + "RdbRemoteQueryPromiseTest0010 error:" + err)
expect(err.message!==null).assertTrue();
done();
} }
expect(errInfo.code).assertEqual("401")
done();
console.info(TAG + "RdbRemoteQueryPromiseTest0010 end") console.info(TAG + "RdbRemoteQueryPromiseTest0010 end")
}) })
/** /**
* @tc.name RelationalStore remotequery test * @tc.name RelationalStore remotequery test
* @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0020 * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0020
* @tc.desc RelationalStore remotequery function test * @tc.desc RelationalStore remotequery function test
*/ */
it('RdbRemoteQueryPromiseTest0020', 0, async function (done){ it('RdbRemoteQueryPromiseTest0020', 0, async function (done){
console.info(TAG + "RdbRemoteQueryPromiseTest0020 start") console.info(TAG + "RdbRemoteQueryPromiseTest0020 start")
let predicates = new data_Rdb.RdbPredicates("test"); let predicates = new data_Rdb.RdbPredicates("test");
predicates.equalTo("name", "zhangsan") predicates.equalTo("name", "zhangsan")
...@@ -187,17 +195,17 @@ export default function relationalStoreQueryTest(){ ...@@ -187,17 +195,17 @@ export default function relationalStoreQueryTest(){
}catch(err){ }catch(err){
console.info(TAG + "RdbRemoteQueryPromiseTest0020 error:" + err) console.info(TAG + "RdbRemoteQueryPromiseTest0020 error:" + err)
} }
done(); done();
console.info(TAG + "RdbRemoteQueryPromiseTest0020 end") console.info(TAG + "RdbRemoteQueryPromiseTest0020 end")
}) })
/** /**
* @tc.name RelationalStore remotequery test * @tc.name RelationalStore remotequery test
* @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0030 * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0030
* @tc.desc RelationalStore remotequery function test * @tc.desc RelationalStore remotequery function test
*/ */
it('RdbRemoteQueryPromiseTest0030', 0, async function (done){ it('RdbRemoteQueryPromiseTest0030', 0, async function (done){
console.info(TAG + "RdbRemoteQueryPromiseTest0030 start") console.info(TAG + "RdbRemoteQueryPromiseTest0030 start")
let predicates = new data_Rdb.RdbPredicates("test"); let predicates = new data_Rdb.RdbPredicates("test");
predicates.equalTo("name", "zhangsan") predicates.equalTo("name", "zhangsan")
...@@ -211,17 +219,17 @@ export default function relationalStoreQueryTest(){ ...@@ -211,17 +219,17 @@ export default function relationalStoreQueryTest(){
}catch(err){ }catch(err){
console.info(TAG + "RdbRemoteQueryPromiseTest0030 error:" + err) console.info(TAG + "RdbRemoteQueryPromiseTest0030 error:" + err)
} }
done(); done();
console.info(TAG + "RdbRemoteQueryPromiseTest0030 end") console.info(TAG + "RdbRemoteQueryPromiseTest0030 end")
}) })
/** /**
* @tc.name RelationalStore remotequery test * @tc.name RelationalStore remotequery test
* @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0040 * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0040
* @tc.desc RelationalStore remotequery function test * @tc.desc RelationalStore remotequery function test
*/ */
it('RdbRemoteQueryPromiseTest0040', 0, async function (done){ it('RdbRemoteQueryPromiseTest0040', 0, async function (done){
console.info(TAG + "RdbRemoteQueryPromiseTest0040 start") console.info(TAG + "RdbRemoteQueryPromiseTest0040 start")
let predicates = new data_Rdb.RdbPredicates("test"); let predicates = new data_Rdb.RdbPredicates("test");
predicates.equalTo("name", "zhangsan") predicates.equalTo("name", "zhangsan")
...@@ -235,17 +243,17 @@ export default function relationalStoreQueryTest(){ ...@@ -235,17 +243,17 @@ export default function relationalStoreQueryTest(){
}catch(err){ }catch(err){
console.info(TAG + "RdbRemoteQueryPromiseTest0040 error:" + err) console.info(TAG + "RdbRemoteQueryPromiseTest0040 error:" + err)
} }
done(); done();
console.info(TAG + "RdbRemoteQueryPromiseTest0040 end") console.info(TAG + "RdbRemoteQueryPromiseTest0040 end")
}) })
/** /**
* @tc.name RelationalStore remotequery test * @tc.name RelationalStore remotequery test
* @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0010 * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0010
* @tc.desc RelationalStore remotequery function test * @tc.desc RelationalStore remotequery function test
*/ */
it('RdbRemoteQueryCallbackTest0010', 0, async function (done){ it('RdbRemoteQueryCallbackTest0010', 0, async function (done){
console.info(TAG + "RdbRemoteQueryCallbackTest0010 start") console.info(TAG + "RdbRemoteQueryCallbackTest0010 start")
let predicates = new data_Rdb.RdbPredicates("test"); let predicates = new data_Rdb.RdbPredicates("test");
predicates.equalTo("name", "zhangsan") predicates.equalTo("name", "zhangsan")
...@@ -255,23 +263,23 @@ export default function relationalStoreQueryTest(){ ...@@ -255,23 +263,23 @@ export default function relationalStoreQueryTest(){
console.info(TAG + "Remote query error" + err) console.info(TAG + "Remote query error" + err)
}else{ }else{
console.info(TAG + "Remote query success") console.info(TAG + "Remote query success")
expect(false).assertTrue(); expect(false).assertTrue();
} }
}) })
}catch(err){ }catch(err){
console.info(TAG + "RdbRemoteQueryCallbackTest0010 error:" + err) console.info(TAG + "RdbRemoteQueryCallbackTest0010 error:" + err)
} }
done(); done();
console.info(TAG + "RdbRemoteQueryCallbackTest0010 end") console.info(TAG + "RdbRemoteQueryCallbackTest0010 end")
}) })
/** /**
* @tc.name RelationalStore remotequery test * @tc.name RelationalStore remotequery test
* @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0020 * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0020
* @tc.desc RelationalStore remotequery function test * @tc.desc RelationalStore remotequery function test
*/ */
it('RdbRemoteQueryCallbackTest0020', 0, async function (done){ it('RdbRemoteQueryCallbackTest0020', 0, async function (done){
console.info(TAG + "RdbRemoteQueryCallbackTest0020 start") console.info(TAG + "RdbRemoteQueryCallbackTest0020 start")
let predicates = new data_Rdb.RdbPredicates("test"); let predicates = new data_Rdb.RdbPredicates("test");
predicates.equalTo("name", "zhangsan") predicates.equalTo("name", "zhangsan")
...@@ -281,23 +289,23 @@ export default function relationalStoreQueryTest(){ ...@@ -281,23 +289,23 @@ export default function relationalStoreQueryTest(){
console.info(TAG + "Remote query error" + err) console.info(TAG + "Remote query error" + err)
}else{ }else{
console.info(TAG + "Remote query success") console.info(TAG + "Remote query success")
expect(false).assertTrue(); expect(false).assertTrue();
} }
}) })
}catch(err){ }catch(err){
console.info(TAG + "RdbRemoteQueryCallbackTest0020 error:" + err) console.info(TAG + "RdbRemoteQueryCallbackTest0020 error:" + err)
} }
done(); done();
console.info(TAG + "RdbRemoteQueryCallbackTest0020 end") console.info(TAG + "RdbRemoteQueryCallbackTest0020 end")
}) })
/** /**
* @tc.name RelationalStore remotequery test * @tc.name RelationalStore remotequery test
* @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0030 * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0030
* @tc.desc RelationalStore remotequery function test * @tc.desc RelationalStore remotequery function test
*/ */
it('RdbRemoteQueryCallbackTest0030', 0, async function (done){ it('RdbRemoteQueryCallbackTest0030', 0, async function (done){
console.info(TAG + "RdbRemoteQueryCallbackTest0020 start") console.info(TAG + "RdbRemoteQueryCallbackTest0020 start")
let predicates = new data_Rdb.RdbPredicates("test"); let predicates = new data_Rdb.RdbPredicates("test");
predicates.equalTo("name", "zhangsan") predicates.equalTo("name", "zhangsan")
...@@ -307,23 +315,23 @@ export default function relationalStoreQueryTest(){ ...@@ -307,23 +315,23 @@ export default function relationalStoreQueryTest(){
console.info(TAG + "Remote query error" + err) console.info(TAG + "Remote query error" + err)
}else{ }else{
console.info(TAG + "Remote query success") console.info(TAG + "Remote query success")
expect(false).assertTrue(); expect(false).assertTrue();
} }
}) })
}catch(err){ }catch(err){
console.info(TAG + "RdbRemoteQueryCallbackTest0030 error:" + err) console.info(TAG + "RdbRemoteQueryCallbackTest0030 error:" + err)
} }
done(); done();
console.info(TAG + "RdbRemoteQueryCallbackTest0030 end") console.info(TAG + "RdbRemoteQueryCallbackTest0030 end")
}) })
/** /**
* @tc.name RelationalStore remotequery test * @tc.name RelationalStore remotequery test
* @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0040 * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0040
* @tc.desc RelationalStore remotequery function test * @tc.desc RelationalStore remotequery function test
*/ */
it('RdbRemoteQueryCallbackTest0040', 0, async function (done){ it('RdbRemoteQueryCallbackTest0040', 0, async function (done){
console.info(TAG + "RdbRemoteQueryCallbackTest0040 start") console.info(TAG + "RdbRemoteQueryCallbackTest0040 start")
let predicates = new data_Rdb.RdbPredicates("test"); let predicates = new data_Rdb.RdbPredicates("test");
predicates.equalTo("name", "zhangsan") predicates.equalTo("name", "zhangsan")
...@@ -333,13 +341,13 @@ export default function relationalStoreQueryTest(){ ...@@ -333,13 +341,13 @@ export default function relationalStoreQueryTest(){
console.info(TAG + "Remote query error" + err) console.info(TAG + "Remote query error" + err)
}else{ }else{
console.info(TAG + "Remote query success") console.info(TAG + "Remote query success")
expect(false).assertTrue(); expect(false).assertTrue();
} }
}) })
}catch(err){ }catch(err){
console.info(TAG + "RdbRemoteQueryCallbackTest0040 error:" + err) console.info(TAG + "RdbRemoteQueryCallbackTest0040 error:" + err)
} }
done(); done();
console.info(TAG + "RdbRemoteQueryCallbackTest0040 end") console.info(TAG + "RdbRemoteQueryCallbackTest0040 end")
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册