未验证 提交 9b1801c0 编写于 作者: O openharmony_ci 提交者: Gitee

!6119 【Distributeddatamgr】【master】用例优化

Merge pull request !6119 from 梁梁/master
......@@ -2240,13 +2240,24 @@ describe('deviceKvStoreCallbackTest', function () {
* @tc.name Test Js Api DeviceKvStore.9.CloseResultSet() testcase 004
*/
it('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0400', 0, async function (done) {
console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0400');
try {
console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0400 start');
let errorInfo = undefined;
try {
kvStore.closeResultSet(1, function(err, data){
if(err != null){
console.error('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0400 e ' + `, error code is ${err.code}, message is ${err.message}`)
}else{
console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0400 success(callback)');
expect(null).assertFail();
}
})
console.info('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0400 success');
}catch(e) {
console.error('SUB_DDM_DKV_DEVICESTORE_CLOSERESULTSET_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail();
errorInfo = e
expect(e.code).assertEqual("401");
}
expect(errorInfo != undefined).assertTrue();
done();
})
......@@ -2413,7 +2424,6 @@ describe('deviceKvStoreCallbackTest', function () {
done();
});
});
console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0100 success');
console.info('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0200 success');
}catch(e) {
console.error('SUB_DDM_DKV_DEVICESTORE_GETENTRIES_0200 e ' + `, error code is ${e.code}, message is ${e.message}`);
......
......@@ -2462,12 +2462,20 @@ describe('deviceKvStorePromiseTest', function () {
*/
it('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0400', 0, async function (done) {
console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0400');
let errorInfo = undefined;
try {
await kvStore.closeResultSet(1).then(() => {
console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0400 success(promise)')
}).catch((err) => {
console.error('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0400 e ')
})
console.info('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0400 success');
}catch(e) {
console.error('SUB_DDM_DKV_DEVICEKVSTORE_CLOSERESULTSET_PROMISE_0400 e ' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail();
errorInfo = e
expect(e.code).assertEqual("401");
}
expect(errorInfo != undefined).assertTrue();
done();
})
......
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import ddm from '@ohos.data.distributedKVStore';
export default function FieldNodeTest(){
describe('FieldNodeTest', function() {
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0100
* @tc.desc Test Js Api FieldNode.AppendChild() testcase 001
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0100
*/
it('SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0100', 0, async function(done) {
try {
let node = new ddm.FieldNode("root");
let child1 = new ddm.FieldNode("child1");
let child2 = new ddm.FieldNode("child2");
let child3 = new ddm.FieldNode("child3");
node.appendChild(child1);
node.appendChild(child2);
node.appendChild(child3);
child1 = null;
child2 = null;
child3 = null;
node = null;
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0100 " + e);
expect(null).assertFail();
}
done();
})
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0200
* @tc.desc Test Js Api FieldNode.AppendChild() testcase 002
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0200
*/
it('SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0200', 0, async function(done) {
try {
let node = new ddm.FieldNode("root");
let child = new ddm.FieldNode("child");
node.appendChild(child);
child = null;
node = null;
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0200 " + e);
expect(null).assertFail();
}
done();
})
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0300
* @tc.desc Test Js Api FieldNode.AppendChild() testcase 003
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0300
*/
it('SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0300', 0, async function(done) {
try {
let node = new ddm.FieldNode("root");
let child = new ddm.FieldNode();
node.appendChild(child);
expect(null).assertFail();
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_APPENDCHILD_0300 is ok :" + e);
}
done();
})
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_TOJSON_0100
* @tc.desc Test Js Api FieldNode.ToJson() testcase 001
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_TOJSON_0100
*/
it('SUB_DDM_DKV_FIELDNODE_TOJSON_0100', 0, async function(done) {
try {
let node = new ddm.FieldNode("root");
let child = new ddm.FieldNode("child");
node.appendChild(child);
} catch (e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_TOJSON_0200
* @tc.desc Test Js Api FieldNode.ToJson() testcase 002
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_TOJSON_0200
*/
it('SUB_DDM_DKV_FIELDNODE_TOJSON_0200', 0, async function(done) {
try {
let node = new ddm.FieldNode("root");
let child = new ddm.FieldNode("child");
node.appendChild(child);
} catch (e) {
expect(null).assertFail();
}
done();
})
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_TOJSON_0300
* @tc.desc Test Js Api FieldNode.ToJson() testcase 003
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_TOJSON_0300
*/
it('SUB_DDM_DKV_FIELDNODE_TOJSON_0300', 0, async function(done) {
try {
let node = new ddm.FieldNode();
let child = new ddm.FieldNode();
node.appendChild(child);
expect(null).assertFail();
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TOJSON_0300 is ok : " + e);
}
done();
})
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_DEFAULT_0100
* @tc.desc Test Js Api FieldNode.default testcase 001
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_DEFAULT_0100
*/
it('SUB_DDM_DKV_FIELDNODE_DEFAULT_0100', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.default = 'first name';
console.info('defaultValue = ' + node.default);
expect(node.default === 'first name').assertTrue()
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_DEFAULT_0100 fail on exception: " + e);
}
done();
})
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_DEFAULT_0100
* @tc.desc Test Js Api FieldNode.nullable testcase 001
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_NULLABLE_0100
*/
it('SUB_DDM_DKV_FIELDNODE_DEFAULT_0100', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.nullable = false;
console.info('nullable = ' + node.nullable);
expect(node.nullable === false).assertTrue()
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_DEFAULT_0100 fail on exception: " + e);
}
done();
})
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_TYPE_0100
* @tc.desc Test Js Api FieldNode.type testcase 001
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_TYPE_0100
*/
it('SUB_DDM_DKV_FIELDNODE_TYPE_0100', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.type = ddm.value.type.STRING;
console.info('type = ' + node.type);
expect(node.type === ddm.type.STRING).assertTrue()
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0100 fail on exception: " + e);
}
done();
})
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_TYPE_0200
* @tc.desc Test Js Api FieldNode.type testcase 002
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_TYPE_0200
*/
it('SUB_DDM_DKV_FIELDNODE_TYPE_0200', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.type = ddm.type.INTEGER;
console.info('type = ' + node.type);
expect(node.type === ddm.type.INTEGER).assertTrue()
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0200 fail on exception: " + e);
}
done();
})
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_TYPE_0300
* @tc.desc Test Js Api FieldNode.type testcase 003
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_TYPE_0300
*/
it('SUB_DDM_DKV_FIELDNODE_TYPE_0300', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.type = ddm.type.FLOAT;
console.info('type = ' + node.type);
expect(node.type === ddm.type.FLOAT).assertTrue()
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0300 fail on exception: " + e);
}
done();
})
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_TYPE_0400
* @tc.desc Test Js Api FieldNode.type testcase 004
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_TYPE_0400
*/
it('SUB_DDM_DKV_FIELDNODE_TYPE_0400', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.type = ddm.type.BYTE_ARRAY;
console.info('type = ' + node.type);
expect(node.type === ddm.type.BYTE_ARRAY).assertTrue()
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0400 fail on exception: " + e);
}
done();
})
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_TYPE_0500
* @tc.desc Test Js Api FieldNode.type testcase 005
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_TYPE_0500
*/
it('SUB_DDM_DKV_FIELDNODE_TYPE_0500', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.type = ddm.type.BOOLEAN;
console.info('type = ' + node.type);
expect(node.type === ddm.ValueType.BOOLEAN).assertTrue()
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0500 fail on exception: " + e);
}
done();
})
/**
* @tc.name SUB_DDM_DKV_FIELDNODE_TYPE_0600
* @tc.desc Test Js Api FieldNode.type testcase 006
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_FIELDNODE_TYPE_0600
*/
it('SUB_DDM_DKV_FIELDNODE_TYPE_0600', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.type = ddm.type.DOUBLE;
console.info('type = ' + node.type);
expect(node.type === ddm.type.DOUBLE).assertTrue()
} catch (e) {
console.info("SUB_DDM_DKV_FIELDNODE_TYPE_0600 fail on exception: " + e);
}
done();
})
})
}
......@@ -20,6 +20,11 @@ import KVManagerPromiseTest from './KvManagerKVPromiseJsTest.js'
import KvStoreResultSetTest from './KvStoreResultSetKVJsTest.js'
import queryTest from './QueryKVJsTest.js'
import SingleKvStoreCallbackTest from './SingleKvStoreKVCallbackJsTest.js'
import FieldNodeTest from './FieldNodeJsTest.js'
import kvStoreBackupCallbackJsunittest from './KvStoreBackupCallbackJsTest.js'
import kvStoreBackupPromiseJsunittest from './KvStoreBackupPromiseJsTest.js'
import schemaTest from './SchemaJsTest.js'
import singleKvStoreEnumTest from './SingleKvStoreEnumJsTest.js'
export default function testsuite() {
SingleKvStorePromiseTest()
deviceKvStoreCallbackTest()
......@@ -29,4 +34,9 @@ export default function testsuite() {
KvStoreResultSetTest()
queryTest()
SingleKvStoreCallbackTest()
FieldNodeTest()
kvStoreBackupCallbackJsunittest()
kvStoreBackupPromiseJsunittest()
schemaTest()
singleKvStoreEnumTest()
}
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
import ddm from '@ohos.data.distributedKVStore';
import abilityFeatureAbility from '@ohos.ability.featureAbility'
var context = abilityFeatureAbility.getContext();
const TEST_BUNDLE_NAME = 'ohos.acts.distributedKvStore';
const TEST_STORE_ID = 'storeId';
var kvManager = null;
var kvStore = null;
function putBatchString(len, prefix) {
let entries = [];
for (var i = 0; i < len; i++) {
entries.push({
key : prefix + i,
value : {
type : ddm.ValueType.STRING,
value : '{"english":{"first":"leda' + i + '", "second":"yang"}}'
}
});
}
return entries;
}
async function testPutAndGet(kvManager, options) {
try {
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.info('testPutAndGet getKVStore success' + JSON.stringify(options));
kvStore = store;
expect(store != null).assertTrue();
}).catch((err) => {
console.info('testPutAndGet getKVStore fail ' + err);
expect(null).assertFail();
});
var canGet = new Promise((resolve, reject) => {
kvStore.on('dataChange', 0, function (data) {
console.info('testPutAndGet resolve on data change: ' + JSON.stringify(data));
resolve(data.deviceId);
});
let entries = putBatchString(10, 'test_key_');
kvStore.putBatch(entries).then((data) => {
console.info('testPutAndGet put success');
expect(data == undefined).assertTrue();
});
setTimeout(() => {
reject(new Error('not resolved in 2 second, reject it.'))
}, 2000);
});
await canGet.then(async function(deviceId) {
var query = new ddm.Query();
query.prefixKey('test_key_');
query.like('$.english.first', 'led%');
if (options.kvStoreType == ddm.KVStoreType.DEVICE_COLLABORATION) {
console.info('testPutAndGet deviceId = ' + deviceId);
query.deviceId(deviceId);
}
await kvStore.getEntries(query).then((entries) => {
console.info('testPutAndGet get success : ' + JSON.stringify(entries));
expect(entries.length == 10).assertTrue();
}).catch((err) => {
console.info('testPutAndGet get fail ' + err);
expect(null).assertFail();
});
}).catch((error) => {
console.info('testPutAndGet canGet fail: ' + error);
expect(null).assertFail();
});
} catch (e) {
console.info('testPutAndGet get exception: ' + e);
}
}
export default function schemaTest(){
describe('schemaTest', function() {
const config = {
bundleName : TEST_BUNDLE_NAME,
context: context,
}
var options = {
createIfMissing : true,
encrypt : false,
backup : false,
autoSync : true,
kvStoreType : ddm.KVStoreType.SINGLE_VERSION,
schema : {},
securityLevel : ddm.SecurityLevel.S1,
}
beforeAll(async function (done) {
try {
console.info("beforeAll: createKVManager (single) with " + JSON.stringify(options));
await ddm.createKVManager(config).then((manager) => {
kvManager = manager;
console.info('beforeAll createKVManager success');
}).catch((err) => {
console.info('beforeAll createKVManager err ' + err);
});
} catch (e) {
console.info("fail on exception: " + e);
expect(null).assertFail();
}
done();
})
afterAll(async function (done) {
console.info('afterAll');
kvManager = null;
kvStore = null;
done();
})
beforeEach(async function (done) {
console.info('beforeEach testcase will update options:' + JSON.stringify(options));
done();
})
afterEach(async function (done) {
console.info('afterEach');
await kvManager.closeKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID, kvStore).then(async () => {
console.info('afterEach closeKVStore success');
await kvManager.deleteKVStore(TEST_BUNDLE_NAME, TEST_STORE_ID).then(() => {
console.info('afterEach deleteKVStore success');
}).catch((err) => {
console.info('afterEach deleteKVStore err ' + err);
});
}).catch((err) => {
console.info('afterEach closeKVStore err ' + err);
});
kvStore = null;
done();
})
/**
* @tc.name SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0100
* @tc.desc Test Js Api Schema.ToJsonString() testcase 001
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0100
*/
it('SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0100', 0, async function(done) {
try {
let first = new ddm.FieldNode('first');
first.type = ddm.ValueType.STRING;
first.nullable = false;
first.default = 'first name';
let second = new ddm.FieldNode('second');
second.type = ddm.ValueType.STRING;
second.nullable = false;
second.default = 'second name';
let english = new ddm.FieldNode('english');
english.type = ddm.ValueType.STRING;
english.appendChild(first);
english.appendChild(second);
let schema = new ddm.Schema();
schema.root.appendChild(english);
schema.indexes = ['$.english.first', '$.english.second'];
} catch (e) {
console.info("schema fail on exception: " + e);
expect(null).assertFail();
}
done();
})
/**
* @tc.name SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0200
* @tc.desc Test Js Api Schema.ToJsonString() testcase 002
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0200
*/
it('SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0200', 0, async function(done) {
try {
let first = new ddm.FieldNode('first');
first.type = ddm.ValueType.STRING;
first.nullable = false;
first.default = 'first name';
let second = new ddm.FieldNode('second');
second.type = ddm.ValueType.STRING;
second.nullable = false;
second.default = 'second name';
let english = new ddm.FieldNode('english');
english.type = ddm.ValueType.STRING;
english.appendChild(first);
english.appendChild(second);
let schema = new ddm.Schema();
schema.root.appendChild(english);
schema.indexes = ['$.english.first', '$.english.second'];
options.kvStoreType = ddm.KVStoreType.DEVICE_COLLABORATION;
options.schema = schema;
await testPutAndGet(kvManager, options);
console.info("schematestPutAndGet done");
} catch (e) {
console.info("schema fail on exception: " + e);
expect(null).assertFail();
}
done();
})
/**
* @tc.name SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0300
* @tc.desc Test Js Api Schema.ToJsonString() testcase 003
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0300
*/
it('SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0300', 0, async function(done) {
try {
let name = new ddm.FieldNode('name');
name.type = ddm.ValueType.INTEGER;
name.nullable = false;
name.default = 0;
let schema = new ddm.Schema();
schema.root.appendChild(name);
schema.indexes = ['$.name'];
schema.mode = 1; // STRICT
options.kvStoreType = ddm.KVStoreType.SINGLE_VERSION;
options.schema = schema;
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.info('SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0300 getKVStore success' + JSON.stringify(options));
kvStore = store;
expect(store != null).assertTrue();
await kvStore.put("test_key_1", '{"name":1}');
await kvStore.put("test_key_2", '{"name":2}');
await kvStore.put("test_key_3", '{"name":3}');
console.info('SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0300 Put success');
});
console.info('SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0300 start Query ...');
var query = new ddm.Query();
query.prefixKey('test_key_');
query.notEqualTo("$.name", 3);
await kvStore.getEntries(query).then((entries) => {
console.info('SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0300 get success : ' + JSON.stringify(entries));
expect(entries.length == 2).assertTrue();
}).catch((err) => {
console.info('SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0300 get fail ' + err);
expect(null).assertFail();
});
} catch (e) {
console.info("SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0300 fail on exception: " + e);
expect(null).assertFail();
}
done();
})
/**
* @tc.name SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0400
* @tc.desc Test Js Api Schema.ToJsonString() testcase 004
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0400
*/
it('SUB_DDM_DKV_SCHEMA_TOJSONSTRING_0400', 0, async function(done) {
try {
let english = new ddm.FieldNode('english');
english.type = ddm.ValueType.STRING;
let schema = new ddm.Schema();
schema.root.appendChild(english);
schema.indexes = []; // indexex set to empty array -> invalid indexes.
expect(null).assertFail();
} catch (e) {
console.info("schema exception is ok: " + e);
}
done();
})
/**
* @tc.name SUB_DDM_DKV_SCHEMA_ROOT_0100
* @tc.desc Test Js Api Schema.root testcase 001
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SCHEMA_ROOT_0100
*/
it('SUB_DDM_DKV_SCHEMA_ROOT_0100', 0, async function(done) {
try {
let english = new ddm.FieldNode('english');
english.type = ddm.ValueType.STRING;
let schema = new ddm.Schema();
expect(schema.root instanceof ddm.FieldNode).assertTrue();
} catch (e) {
console.info("schema fail on exception: " + e);
expect(null).assertFail();
}
done();
})
/**
* @tc.name SUB_DDM_DKV_SCHEMA_INDEXES_0100
* @tc.desc Test Js Api Schema.indexes testcase 001
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SCHEMA_INDEXES_0100
*/
it('SUB_DDM_DKV_SCHEMA_INDEXES_0100', 0, async function(done) {
try {
let schema = new ddm.Schema();
schema.indexes = ['$.english.first', '$.english.second'];
expect(schema.indexes[0] === '$.english.first' && schema.indexes[1] === '$.english.second').assertTrue();
} catch (e) {
console.info("schema fail on exception: " + e);
expect(null).assertFail();
}
done();
})
/**
* @tc.name SUB_DDM_DKV_SCHEMA_MODE_0100
* @tc.desc Test Js Api Schema.mode testcase 001
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SCHEMA_MODE_0100
*/
it('SUB_DDM_DKV_SCHEMA_MODE_0100', 0, async function(done) {
try {
let schema = new ddm.Schema();
schema.mode = 1;
console.info("schema mode = "+schema.mode)
expect(schema.mode === 1).assertTrue();
} catch (e) {
console.info("schema fail on exception: " + e);
expect(null).assertFail();
}
done();
})
/**
* @tc.name SUB_DDM_DKV_SCHEMA_MODE_0200
* @tc.desc Test Js Api Schema.mode testcase 002
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SCHEMA_MODE_0200
*/
it('SUB_DDM_DKV_SCHEMA_MODE_0200', 0, async function(done) {
try {
let schema = new ddm.Schema();
schema.mode = 0;
console.info("schema mode = "+schema.mode)
expect(schema.mode === 0).assertTrue();
} catch (e) {
console.info("schema fail on exception: " + e);
expect(null).assertFail();
}
done();
})
/**
* @tc.name SUB_DDM_DKV_SCHEMA_SKIP_0100
* @tc.desc Test Js Api Schema.skip testcase 001
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SCHEMA_SKIP_0100
*/
it('SUB_DDM_DKV_SCHEMA_SKIP_0100', 0, async function(done) {
try {
let schema = new ddm.Schema();
schema.skip = 0;
expect(schema.skip === 0).assertTrue();
} catch (e) {
console.info("schema fail on exception: " + e);
expect(null).assertFail();
}
done();
})
})
}
\ No newline at end of file
/*
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium'
import factory from '@ohos.data.distributedKVStore';
export default function singleKvStoreEnumTest(){
describe('singleKvStoreEnumTest', function () {
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_KEY_LENGTH_0100
* @tc.desc Test Js Enum Value Constants.MAX_KEY_LENGTH
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_KEY_LENGTH_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_KEY_LENGTH_0100', 0, function () {
var maxKeyLength = factory.Constants.MAX_KEY_LENGTH;
console.info('maxKeyLength = ' + maxKeyLength);
expect(maxKeyLength == 1024).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_VALUE_LENGTH_0100
* @tc.desc Test Js Enum Value Constants.MAX_VALUE_LENGTH
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_VALUE_LENGTH_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_VALUE_LENGTH_0100', 0, function () {
var maxValueLength = factory.Constants.MAX_VALUE_LENGTH;
console.info('maxValueLength = ' + maxValueLength);
expect(maxValueLength == 4194303).assertTrue();
expect(factory.Constants.MAX_VALUE_LENGTH).assertEqual(4194303);
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_VALUE_LENGTH_0200
* @tc.desc Test Js Enum Value Constants.MAX_VALUE_LENGTH
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_VALUE_LENGTH_0200
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_VALUE_LENGTH_0200', 0, function () {
try {
factory.Constants.MAX_VALUE_LENGTH = 123;
} catch (e) {
console.info('can NOT set value to MAX_VALUE_LENGTH : ' + e);
expect(factory.Constants.MAX_VALUE_LENGTH).assertEqual(4194303);
}
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_KEY_LENGTH_DEVICE_0100
* @tc.desc Test Js Enum Value Constants.MAX_KEY_LENGTH_DEVICE
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_KEY_LENGTH_DEVICE_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_KEY_LENGTH_DEVICE_0100', 0, function () {
var maxKeyLengthDevice = factory.Constants.MAX_KEY_LENGTH_DEVICE;
console.info('maxKeyLengthDevice = ' + maxKeyLengthDevice);
expect(maxKeyLengthDevice == 896).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_STORE_ID_LENGTH_0100
* @tc.desc Test Js Enum Value Constants.MAX_STORE_ID_LENGTH
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_STORE_ID_LENGTH_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_STORE_ID_LENGTH_0100', 0, function () {
var maxStoreIdLength = factory.Constants.MAX_STORE_ID_LENGTH;
console.info('maxStoreIdLength = ' + maxStoreIdLength);
expect(maxStoreIdLength == 128).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_QUERY_LENGTH_0100
* @tc.desc Test Js Enum Value Constants.MAX_QUERY_LENGTH
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_QUERY_LENGTH_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_QUERY_LENGTH_0100', 0, function () {
var maxQueryLength = factory.Constants.MAX_QUERY_LENGTH;
console.info('maxQueryLength = ' + maxQueryLength);
expect(maxQueryLength == 512000).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_BATCH_SIZE_0100
* @tc.desc Test Js Enum Value Constants.MAX_BATCH_SIZE
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_BATCH_SIZE_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_MAX_BATCH_SIZE_0100', 0, function () {
var maxBatchSize = factory.Constants.MAX_BATCH_SIZE;
console.info('maxBatchSize = ' + maxBatchSize);
expect(maxBatchSize == 128).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_STRING_0100
* @tc.desc Test Js Enum Value Valuetype.STRING
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_STRING_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_STRING_0100', 0, function () {
var string = factory.ValueType.STRING;
console.info('string = ' + string);
expect(string == 0).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_INTEGER_0100
* @tc.desc Test Js Enum Value Valuetype.INTEGER
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_INTEGER_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_INTEGER_0100', 0, function () {
var integer = factory.ValueType.INTEGER;
console.info('integer = ' + integer);
expect(integer == 1).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_FLOAT_0100
* @tc.desc Test Js Enum Value Valuetype.FLOAT
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_FLOAT_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_FLOAT_0100', 0, function () {
var float = factory.ValueType.FLOAT;
console.info('float = ' + float);
expect(float == 2).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_BYTEARRAY_0100
* @tc.desc Test Js Enum Value Valuetype.BYTEARRAY
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_BYTEARRAY_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_BYTEARRAY_0100', 0, function () {
var byteArray = factory.ValueType.BYTE_ARRAY;
console.info('byteArray = ' + byteArray);
expect(byteArray == 3).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_BOOLEAN_0100
* @tc.desc Test Js Enum Value Valuetype.BOOLEAN
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_BOOLEAN_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_BOOLEAN_0100', 0, function () {
var boolean = factory.ValueType.BOOLEAN;
console.info('boolean = ' + boolean);
expect(boolean == 4).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_DOUBLE_0100
* @tc.desc Test Js Enum Value Valuetype.DOUBLE
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_DOUBLE_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_DOUBLE_0100', 0, function () {
var double = factory.ValueType.DOUBLE;
console.info('double = ' + double);
expect(double == 5).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_PULL_ONLY_0100
* @tc.desc Test Js Enum Value Syncmode.PULL_ONLY
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_PULL_ONLY_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_PULL_ONLY_0100', 0, function () {
var pullonly = factory.SyncMode.PULL_ONLY;
console.info('pullonly = ' + pullonly);
expect(pullonly == 0).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_PUSH_ONLY_0100
* @tc.desc Test Js Enum Value Syncmode.PUSH_ONLY
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_PUSH_ONLY_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_PUSH_ONLY_0100', 0, function () {
var pushonly = factory.SyncMode.PUSH_ONLY;
console.info('pushonly = ' + pushonly);
expect(pushonly == 1).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_PUSH_PULL_0100
* @tc.desc Test Js Enum Value Syncmode.PUSH_PULL
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_PUSH_PULL_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_PUSH_PULL_0100', 0, function () {
var pushpull = factory.SyncMode.PUSH_PULL;
console.info('pushpull = ' + pushpull);
expect(pushpull == 2).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_SUBSCRIBE_TYPE_LOCAL_0100
* @tc.desc Test Js Enum Value Subscribetype.SUBSCRIBE_TYPE_LOCAL
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_SUBSCRIBE_TYPE_LOCAL_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_SUBSCRIBE_TYPE_LOCAL_0100', 0, function () {
var local = factory.SubscribeType.SUBSCRIBE_TYPE_LOCAL;
console.info('local = ' + local);
expect(local == 0).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_SUBSCRIBE_TYPE_REMOTE_0100
* @tc.desc Test Js Enum Value Subscribetype.SUBSCRIBE_TYPE_REMOTE
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_SUBSCRIBE_TYPE_REMOTE_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_SUBSCRIBE_TYPE_REMOTE_0100', 0, function () {
var remote = factory.SubscribeType.SUBSCRIBE_TYPE_REMOTE;
console.info('remote = ' + remote);
expect(remote == 1).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_SUBSCRIBE_TYPE_ALL_0100
* @tc.desc Test Js Enum Value Subscribetype.SUBSCRIBE_TYPE_ALL
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_SUBSCRIBE_TYPE_ALL_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_SUBSCRIBE_TYPE_ALL_0100', 0, function () {
var all = factory.SubscribeType.SUBSCRIBE_TYPE_ALL;
console.info('all = ' + all);
expect(all == 2).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_DEVICE_COLLABORATION_0100
* @tc.desc Test Js Enum Value Kvstoretype.DEVICE_COLLABORATION
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_DEVICE_COLLABORATION_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_DEVICE_COLLABORATION_0100', 0, function () {
var collaboration = factory.KVStoreType.DEVICE_COLLABORATION;
console.info('collaboration = ' + collaboration);
expect(collaboration == 0).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_SINGLE_VERSION_0100
* @tc.desc Test Js Enum Value Kvstoretype.SINGLE_VERSION
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_SINGLE_VERSION_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_SINGLE_VERSION_0100', 0, function () {
var single = factory.KVStoreType.SINGLE_VERSION;
console.info('single = ' + single);
expect(single == 1).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_S1_0100
* @tc.desc Test Js Enum Value Securitylevel.S1
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_S1_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_S1_0100', 0, function () {
var s1 = factory.SecurityLevel.S1;
console.info('s1 = ' + s1);
expect(s1 == 2).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_S2_0100
* @tc.desc Test Js Enum Value Securitylevel.S2
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_S2_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_S2_0100', 0, function () {
var s2 = factory.SecurityLevel.S2;
console.info('s2 = ' + s2);
expect(s2 == 3).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_S3_0100
* @tc.desc Test Js Enum Value Securitylevel.S3
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_S3_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_S3_0100', 0, function () {
var s3 = factory.SecurityLevel.S3;
console.info('s3 = ' + s3);
expect(s3 == 5).assertTrue()
})
/**
* @tc.name SUB_DDM_DKV_SINGLEKVSTOREENUM_S4_0100
* @tc.desc Test Js Enum Value Securitylevel.S4
* @tc.type: FUNC
* @tc.number: SUB_DDM_DKV_SINGLEKVSTOREENUM_S4_0100
*/
it('SUB_DDM_DKV_SINGLEKVSTOREENUM_S4_0100', 0, function () {
var s4 = factory.SecurityLevel.S4;
console.info('s4 = ' + s4);
expect(s4 == 6).assertTrue()
})
})
}
......@@ -2124,10 +2124,17 @@ describe('deviceKvStoreCallbackTest', function () {
it('testDeviceKvStoreCloseResultSet104', 0, async function (done) {
console.info('testDeviceKvStoreCloseResultSet104');
try {
kvStore.closeResultSet(1, (err, data) => {
if(err != null){
console.info('testDeviceKvStoreCloseResultSet104 e ' + err);
}else{
console.info('testDeviceKvStoreCloseResultSet104 success(callback)');
expect(null).assertFail();
}
})
console.info('testDeviceKvStoreCloseResultSet104 success');
}catch(e) {
console.info('testDeviceKvStoreCloseResultSet104 e ' + e);
expect(null).assertFail();
}
done();
})
......
......@@ -2339,12 +2339,21 @@ describe('deviceKvStorePromiseTest', function () {
*/
it('testDeviceKvStoreCloseResultSet004', 0, async function (done) {
console.info('testDeviceKvStoreCloseResultSet004');
let errorInfo = undefined;
try {
await kvStore.closeResultSet(1).then(() => {
console.info('testDeviceKvStoreCloseResultSet004 success');
expect(null).assertFail();
}).catch(err => {
console.info('testDeviceKvStoreCloseResultSet004 err ' + err);
errorInfo = err
})
console.info('testDeviceKvStoreCloseResultSet004 success');
}catch(e) {
console.info('testDeviceKvStoreCloseResultSet004 e ' + e);
expect(null).assertFail();
errorInfo = e
}
expect(errorInfo != undefined).assertTrue();
done();
})
......
......@@ -719,7 +719,7 @@ describe('rdbstoreInsertTest', function () {
})
resultSet = null
})
await sleep(2000)
done()
console.info(TAG + "************* testRdbStorebatchInsertCallback0001 end *************");
})
......@@ -787,7 +787,7 @@ describe('rdbstoreInsertTest', function () {
done();
})
})
await sleep(2000)
resultSet = null
done()
console.info(TAG + "************* testRdbStorebatchInsertCallback0002 end *************");
......@@ -836,14 +836,11 @@ describe('rdbstoreInsertTest', function () {
const name = resultSet.getString(resultSet.getColumnIndex("name"))
const age = resultSet.getLong(resultSet.getColumnIndex("age"))
const salary = resultSet.getDouble(resultSet.getColumnIndex("salary"))
console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary + ", blobType=" + blobType);
console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary);
expect(1).assertEqual(id);
expect("zhangsan").assertEqual(name)
expect(18).assertEqual(age)
expect(100.5).assertEqual(salary)
expect(1).assertEqual(blobType[0])
expect(2).assertEqual(blobType[1])
expect(3).assertEqual(blobType[2])
} catch (e) {
console.info("BatchInsert1 error " + e);
}
......@@ -857,7 +854,7 @@ describe('rdbstoreInsertTest', function () {
const name = resultSet.getString(resultSet.getColumnIndex("name"))
const age = resultSet.getLong(resultSet.getColumnIndex("age"))
const salary = resultSet.getDouble(resultSet.getColumnIndex("salary"))
console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary + ", blobType=" + blobType);
console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary);
expect(2).assertEqual(id);
expect("lisi").assertEqual(name)
expect(23).assertEqual(age)
......@@ -879,7 +876,7 @@ describe('rdbstoreInsertTest', function () {
const name = resultSet.getString(resultSet.getColumnIndex("name"))
const age = resultSet.getLong(resultSet.getColumnIndex("age"))
const salary = resultSet.getDouble(resultSet.getColumnIndex("salary"))
console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary + ", blobType=" + blobType);
console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary);
expect(4).assertEqual(id);
expect("zhangmaowen").assertEqual(name)
expect(25).assertEqual(age)
......@@ -894,6 +891,7 @@ describe('rdbstoreInsertTest', function () {
done();
})
})
await sleep(2000)
resultSet = null
done();
console.info(TAG + "************* testRdbStorebatchInsertCallback0003 end *************");
......@@ -934,14 +932,11 @@ describe('rdbstoreInsertTest', function () {
const name = resultSet.getString(resultSet.getColumnIndex("name"))
const age = resultSet.getLong(resultSet.getColumnIndex("age"))
const salary = resultSet.getDouble(resultSet.getColumnIndex("salary"))
console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary + ", blobType=" + blobType);
console.info(TAG + "id=" + id + ", name=" + name + ", age=" + age + ", salary=" + salary);
expect(56).assertEqual(id);
expect("zhangsan55").assertEqual(name)
expect(55).assertEqual(age)
expect(56).assertEqual(salary)
expect(1).assertEqual(blobType[0])
expect(2).assertEqual(blobType[1])
expect(3).assertEqual(blobType[2])
} catch (e) {
console.info("BatchInsert1 error " + e);
}
......@@ -949,6 +944,7 @@ describe('rdbstoreInsertTest', function () {
done();
})
})
await sleep(2000)
resultSet = null;
done()
console.info(TAG + "************* testRdbStorebatchInsertCallback0004 end *************");
......@@ -1012,6 +1008,7 @@ describe('rdbstoreInsertTest', function () {
done();
})
})
await sleep(2000)
resultSet = null;
done();
console.info(TAG + "************* testRdbStorebatchInsertCallback0005 end *************");
......@@ -1060,7 +1057,7 @@ describe('rdbstoreInsertTest', function () {
expect(null).assertFail();
}
})
await sleep(2000)
done()
console.info(TAG + "************* testRdbStorebatchInsertCallback0006 end *************");
})
......@@ -1071,23 +1068,24 @@ describe('rdbstoreInsertTest', function () {
* @tc.number SUB_DDM_AppDataFWK_JSRDB_BatchInsert_Callback_0700
* @tc.desc rdb insert test
*/
it('testRdbStorebatchInsertCallback0007', 0, async function (done) {
it('testRdbStorebatchInsertCallback0007', 0, async function (done) {
console.info(TAG + "************* testRdbStorebatchInsertCallback0007 start *************");
await rdbStore.executeSql(CREATE_TABLE_NAME + "Callback7" + CREATE_TABLE).then(async () => {
await rdbStore.batchInsert("testCallback7", (err,data) => {
console.info(TAG + "Affect row is " + data)
if(err != null){
expect(null).assertFail();
}else{
expect(data).assertEqual(-1)
}
}).then((data) => {
console.info(TAG + "Batch insert fail ,affect row number is: " + data)
await rdbStore.executeSql(CREATE_TABLE_NAME + "Callback7" + CREATE_TABLE).then(async () => {
await rdbStore.batchInsert("testCallback7", (err,data) => {
console.info(TAG + "Affect row is " + data)
if(err != null){
expect(null).assertFail();
}else{
expect(data).assertEqual(-1)
})
}).catch((err) => {
expect(null).assertFail();
}
}).then((data) => {
console.info(TAG + "Batch insert fail ,affect row number is: " + data)
expect(data).assertEqual(-1)
})
}).catch((err) => {
expect(null).assertFail();
})
await sleep(2000)
done()
console.info(TAG + "************* testRdbStorebatchInsertCallback0007 end *************");
})
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册