提交 108d1f7a 编写于 作者: Y yanglifeng1217

<modified>

Signed-off-by: Nyanglifeng1217 <yanglifeng5@huawei.com>
上级 e5d934a8
...@@ -2124,9 +2124,9 @@ describe('deviceKvStoreCallbackTest', function () { ...@@ -2124,9 +2124,9 @@ describe('deviceKvStoreCallbackTest', function () {
await kvStore.putBatch(entries, async function (err, data) { await kvStore.putBatch(entries, async function (err, data) {
console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0700 putBatch success'); console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0700 putBatch success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
let predicates = new dataSharePredicates.DataSharePredicates(); let query = new factory.Query();
predicates.inKeys("batch_test"); query.prefixKey("batch_test");
await kvStore.getResultSet(localDeviceId, predicates, async function (err, result) { await kvStore.getResultSet(localDeviceId, query, async function (err, result) {
console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0700 getResultSet success'); console.info('SUB_DDM_DKV_DEVICESTORE_GETRESULTSET_0700 getResultSet success');
resultSet = result; resultSet = result;
expect(resultSet.getCount() == 10).assertTrue(); expect(resultSet.getCount() == 10).assertTrue();
......
...@@ -2349,9 +2349,9 @@ describe('deviceKvStorePromiseTest', function () { ...@@ -2349,9 +2349,9 @@ describe('deviceKvStorePromiseTest', function () {
await kvStore.putBatch(entries).then( async (err) => { await kvStore.putBatch(entries).then( async (err) => {
console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0700 putBatch success'); console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0700 putBatch success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
let predicates = new dataSharePredicates.DataSharePredicates(); let query = new factory.Query();
predicates.inKeys("batch_test"); query.prefixKey("batch_test");
await kvStore.getResultSet(localDeviceId, predicates).then( async (result) => { await kvStore.getResultSet(localDeviceId, query).then( async (result) => {
console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0700 getResultSet success'); console.info('SUB_DDM_DKV_DEVICEKVSTORE_GETRESULTSET_PROMISE_0700 getResultSet success');
resultSet = result; resultSet = result;
expect(resultSet.getCount() == 10).assertTrue(); expect(resultSet.getCount() == 10).assertTrue();
......
...@@ -775,19 +775,14 @@ describe('SingleKvStoreCallbackTest', function () { ...@@ -775,19 +775,14 @@ describe('SingleKvStoreCallbackTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700', 0, async function (done) {
console.log('SingleKvStoreDeletePredicatesCallbackTest001'); console.log('SingleKvStoreDeletePredicatesCallbackTest001');
try { try {
let predicates = new dataShare.DataSharePredicates(); await kvStore.delete(KEY_TEST_STRING_ELEMENT, function (err,data) {
await kvStore.delete(predicates, function (err,data) { console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700 delete err: ' + err);
if (err == undefined) { expect(err == undefined).assertTrue();
console.log('SingleKvStoreDeletePredicatesCallbackTest001 delete success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700 expect fin');
expect(null).assertFail();
} else {
console.error('SingleKvStoreDeletePredicatesCallbackTest001 delete fail' + err`, error code is ${err.code}, message is ${err.message}`);
expect(err != undefined).assertTrue();
}
done(); done();
}); });
}catch(e) { }catch(e) {
console.error('SingleKvStoreDeletePredicatesCallbackTest001 e' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2700 e' + `, error code is ${e.code}, message is ${e.message}`);
expect(e.code == 401).assertTrue(); expect(e.code == 401).assertTrue();
done(); done();
} }
...@@ -802,13 +797,10 @@ describe('SingleKvStoreCallbackTest', function () { ...@@ -802,13 +797,10 @@ describe('SingleKvStoreCallbackTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2800', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2800', 0, async function (done) {
console.log('SingleKvStoreDeletePredicatesCallbackTest002'); console.log('SingleKvStoreDeletePredicatesCallbackTest002');
try { try {
let predicates = new dataShare.DataSharePredicates();
let arr = ["name"];
predicates.inKeys(arr);
await kvStore.put("name", "Bob", async function (err, data) { await kvStore.put("name", "Bob", async function (err, data) {
console.log('SingleKvStoreDeletePredicatesCallbackTest002 put success'); console.log('SingleKvStoreDeletePredicatesCallbackTest002 put success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
await kvStore.delete(predicates, function (err,data) { await kvStore.delete("name", function (err,data) {
console.log('SingleKvStoreDeletePredicatesCallbackTest002 delete success'); console.log('SingleKvStoreDeletePredicatesCallbackTest002 delete success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
done(); done();
...@@ -828,23 +820,20 @@ describe('SingleKvStoreCallbackTest', function () { ...@@ -828,23 +820,20 @@ describe('SingleKvStoreCallbackTest', function () {
* @tc.name Test Js Api SingleKvStore.Delete() testcase 003 * @tc.name Test Js Api SingleKvStore.Delete() testcase 003
*/ */
it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900', 0, async function (done) {
console.log('SingleKvStoreDeletePredicatesCallbackTest003'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900');
try { try {
let predicates = new dataShare.DataSharePredicates();
let arr = [null]; let arr = [null];
predicates.inKeys(arr);
await kvStore.put("name", "Bob", async function (err, data) { await kvStore.put("name", "Bob", async function (err, data) {
console.log('SingleKvStoreDeletePredicatesCallbackTest003 put success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900 put success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
await kvStore.delete(predicates, function (err,data) { console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900 expect finash');
console.log('SingleKvStoreDeletePredicatesCallbackTest003 delete success: '+err);
expect(err == undefined).assertTrue();
done();
});
}) })
await kvStore.delete(arr, function (err,data) {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900 delete success: '+err);
});
} catch(e) { } catch(e) {
console.error('SingleKvStoreDeletePredicatesCallbackTest003 e' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETE_CALLBACK_2900 e' + `, error code is ${e.code}, message is ${e.message}`);
expect(null).assertFail(); expect(e.code == 401).assertTrue();
done(); done();
} }
}) })
...@@ -2228,8 +2217,8 @@ describe('SingleKvStoreCallbackTest', function () { ...@@ -2228,8 +2217,8 @@ describe('SingleKvStoreCallbackTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULT_CALLBACK_7800', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULT_CALLBACK_7800', 0, async function (done) {
console.log('SingleKvStoreGetResultSetPredicatesCallbackTest001'); console.log('SingleKvStoreGetResultSetPredicatesCallbackTest001');
try { try {
let predicates = new dataShare.DataSharePredicates(); let query = new factory.Query();
await kvStore.getResultSet(predicates).then((result) => { await kvStore.getResultSet(query).then((result) => {
console.log('SingleKvStoreGetResultSetPredicatesCallbackTest001 getResultSet success'); console.log('SingleKvStoreGetResultSetPredicatesCallbackTest001 getResultSet success');
}).catch((err) => { }).catch((err) => {
console.error('SingleKvStoreGetResultSetPredicatesCallbackTest001 getResultSet fail ' + err`, error code is ${err.code}, message is ${err.message}`); console.error('SingleKvStoreGetResultSetPredicatesCallbackTest001 getResultSet fail ' + err`, error code is ${err.code}, message is ${err.message}`);
......
...@@ -771,13 +771,12 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -771,13 +771,12 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100', 0, async function (done) {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100');
try { try {
let predicates = new dataShare.DataSharePredicates(); await kvStore.delete("KEY_TEST_STRING_ELEMENTS").then((data) => {
await kvStore.delete(predicates).then((data) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 delete success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 delete success');
expect(null).assertFail();
}).catch((err) => { }).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 delete fail ' + `, error code is ${err.code}, message is ${err.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 delete fail err ' + err);
expect(err != undefined).assertTrue(); expect(err == undefined).assertTrue();
done();
}); });
}catch(e) { }catch(e) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 e' + `, error code is ${e.code}, message is ${e.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0100 e' + `, error code is ${e.code}, message is ${e.message}`);
...@@ -795,13 +794,10 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -795,13 +794,10 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200', 0, async function (done) {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200');
try { try {
let predicates = new dataShare.DataSharePredicates();
let arr = ["name"];
predicates.inKeys(arr);
await kvStore.put("name", "Bob").then(async (data) => { await kvStore.put("name", "Bob").then(async (data) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200 put success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200 put success');
expect(data == undefined).assertTrue(); expect(data == undefined).assertTrue();
await kvStore.delete(predicates).then((data) => { await kvStore.delete("name").then((data) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200 delete success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0200 delete success');
expect(data == undefined).assertTrue(); expect(data == undefined).assertTrue();
}).catch((err) => { }).catch((err) => {
...@@ -828,16 +824,14 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -828,16 +824,14 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300', 0, async function (done) {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300');
try { try {
let predicates = new dataShare.DataSharePredicates();
let arr = [null];
predicates.inKeys(arr);
await kvStore.put("name", "Bob").then(async (data) => { await kvStore.put("name", "Bob").then(async (data) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 put success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 put success');
}).catch((err) => { }).catch((err) => {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 put fail ' + `, error code is ${err.code}, message is ${err.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 put fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail(); expect(null).assertFail();
}); });
await kvStore.delete(predicates, function (err,data) { await kvStore.delete("name", function (err,data) {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 delete success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_DELETEPREDICATES_PROMISE_0300 delete success');
expect(err != undefined).assertTrue(); expect(err != undefined).assertTrue();
done(); done();
...@@ -1553,24 +1547,29 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1553,24 +1547,29 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100');
try { try {
let values = []; let entries = [];
let arr1 = new Uint8Array([4,5,6,7]); for (var i = 0; i < 10; i++) {
let arr2 = new Uint8Array([4,5,6,7,8]); var key = 'batch_test_number_key';
let vb1 = {key : "name_1", value : arr1}; var entry = {
let vb2 = {key : "name_2", value : arr2}; key : key + i,
values.push(vb1); value : {
values.push(vb2); type : factory.ValueType.DOUBLE,
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 values: ' + JSON.stringify(values)); value : 2.00
await kvStore.putBatch(values).then(async (err) => { }
}
entries.push(entry);
}
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 entries: ' + JSON.stringify(entries));
await kvStore.putBatch(entries).then(async (err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 putBatch success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 putBatch success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
var query = new factory.Query(); var query = new factory.Query();
query.prefixKey("name_"); query.prefixKey("batch_test_");
await kvStore.getEntries(query).then((entrys) => { await kvStore.getEntries(query).then((entrys) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 getEntries success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 getEntries success');
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 entrys.length: ' + entrys.length); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 entrys.length: ' + entrys.length);
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 entrys[0]: ' + JSON.stringify(entrys[1])); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 entrys[0]: ' + JSON.stringify(entrys[1]));
expect(entrys.length == 2).assertTrue(); expect(entrys.length == 10).assertTrue();
done(); done();
}); });
}); });
...@@ -1590,22 +1589,29 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1590,22 +1589,29 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200');
try { try {
let values = []; let entries = [];
let vb1 = {key : "name_1", value : "arr1"}; for (var i = 0; i < 10; i++) {
let vb2 = {key : "name_2", value : "arr2"}; var key = 'key_test_int';
values.push(vb1); var entry = {
values.push(vb2); key: key + i,
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 values: ' + JSON.stringify(values)); value: {
await kvStore.putBatch(values).then(async (err) => { type: factory.ValueType.INTEGER,
value: '123'
}
}
entries.push(entry);
}
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 entries: ' + JSON.stringify(entries));
await kvStore.putBatch(entries).then(async (err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 putBatch success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0100 putBatch success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
var query = new factory.Query(); var query = new factory.Query();
query.prefixKey("name_"); query.prefixKey("key_test_");
await kvStore.getEntries(query).then((entrys) => { await kvStore.getEntries(query).then((entrys) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 getEntries success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 getEntries success');
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 entrys.length: ' + entrys.length); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 entrys.length: ' + entrys.length);
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 entrys[0]: ' + JSON.stringify(entrys[1])); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 entrys[0]: ' + JSON.stringify(entrys[1]));
expect(entrys.length == 2).assertTrue(); expect(entrys.length == 10).assertTrue();
done(); done();
}).catch((err) => { }).catch((err) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 delete fail ' + err); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0200 delete fail ' + err);
...@@ -1631,24 +1637,29 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1631,24 +1637,29 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300');
try { try {
let values = []; let entries = [];
let vb1 = {key : "name_1", value : 123}; for (var i = 0; i < 10; i++) {
let vb2 = {key : "name_2", value : 321.0}; var key = 'key_test_boolean';
let vb3 = {key : "name_3", value : 321.00}; var entry = {
values.push(vb1); key: key + i,
values.push(vb2); value: {
values.push(vb3); type: factory.ValueType.BOOLEAN,
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 values: ' + JSON.stringify(values)); value: 'true'
await kvStore.putBatch(values).then(async (err) => { }
}
entries.push(entry);
}
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 entries: ' + JSON.stringify(entries));
await kvStore.putBatch(entries).then(async (err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 putBatch success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 putBatch success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
var query = new factory.Query(); var query = new factory.Query();
query.prefixKey("name_"); query.prefixKey("key_test_");
await kvStore.getEntries(query).then((entrys) => { await kvStore.getEntries(query).then((entrys) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 getEntries success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 getEntries success');
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 entrys.length: ' + entrys.length); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 entrys.length: ' + entrys.length);
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 entrys[0]: ' + JSON.stringify(entrys[2])); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0300 entrys[0]: ' + JSON.stringify(entrys[2]));
expect(entrys.length == 3).assertTrue(); expect(entrys.length == 10).assertTrue();
done(); done();
}); });
}); });
...@@ -1668,22 +1679,29 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1668,22 +1679,29 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400');
try { try {
let values = []; let entries = [];
let vb1 = {key : "name_1", value : true}; for (var i = 0; i < 10; i++) {
let vb2 = {key : "name_2", value : false}; var key = 'key_test_float';
values.push(vb1); var entry = {
values.push(vb2); key: key + i,
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 values: ' + JSON.stringify(values)); value: {
await kvStore.putBatch(values).then(async (err) => { type: factory.ValueType.FLOAT,
value: '321.12'
}
}
entries.push(entry);
}
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 entries: ' + JSON.stringify(entries));
await kvStore.putBatch(entries).then(async (err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 putBatch success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 putBatch success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
var query = new factory.Query(); var query = new factory.Query();
query.prefixKey("name_"); query.prefixKey("key_test_");
await kvStore.getEntries(query).then((entrys) => { await kvStore.getEntries(query).then((entrys) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 getEntries success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 getEntries success');
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 entrys.length: ' + entrys.length); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 entrys.length: ' + entrys.length);
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 entrys[0]: ' + JSON.stringify(entrys[1])); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0400 entrys[0]: ' + JSON.stringify(entrys[1]));
expect(entrys.length == 2).assertTrue(); expect(entrys.length == 10).assertTrue();
done(); done();
}); });
}); });
...@@ -1703,23 +1721,32 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -1703,23 +1721,32 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500', 0, async function (done) {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500');
try { try {
let values = []; let entries = [];
let vb1 = {key : "name_1", value : null}; for (var i = 0; i < 10; i++) {
let vb2 = {key : "name_2", value : null}; var key = 'key_test_string';
values.push(vb1); var entry = {
values.push(vb2); key: key + i,
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 values: ' + JSON.stringify(values)); value: {
await kvStore.putBatch(values).then(async (err) => { type: factory.ValueType.STRING,
value: 'value-string-001'
}
}
entries.push(entry);
}
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entries: ' + JSON.stringify(entries));
await kvStore.putBatch(entries).then(async (err) => {
console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 putBatch success'); console.info('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 putBatch success');
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
var query = new factory.Query(); var query = new factory.Query();
query.prefixKey("name_"); query.prefixKey("key_test_");
await kvStore.getEntries(query).then((entrys) => { await kvStore.getEntries(query).then((entrys) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 getEntries success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 getEntries success');
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys.length: ' + entrys.length); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys.length: ' + entrys.length);
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys[0]: ' + JSON.stringify(entrys[1])); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys[1]: ' + JSON.stringify(entrys[1]));
expect(entrys.length == 2).assertTrue(); expect(entrys.length == 10).assertTrue();
expect(entrys[0].value == null).assertTrue(); console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys[0]: ' + JSON.stringify(entrys[0]));
console.log('SUB_DDM_DKV_SINGLEKVSTORE_PUTBATCHVALUE_PROMISE_0500 entrys[0]: ' + JSON.stringify(entrys[0].value));
expect(entrys[0].value.value == 'value-string-001').assertTrue();
done(); done();
}); });
}); });
...@@ -2762,9 +2789,9 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2762,9 +2789,9 @@ describe('SingleKvStorePromiseTest', function () {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0700 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0700 putBatch fail ' + `, error code is ${err.code}, message is ${err.message}`);
expect(null).assertFail(); expect(null).assertFail();
}); });
let predicates = new dataShare.DataSharePredicates(); let query = new factory.Query();
predicates.prefixKey("name_"); query.prefixKey("name_");
await kvStore.getResultSet(predicates).then((result) => { await kvStore.getResultSet(query).then((result) => {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0700 getResultSet success'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0700 getResultSet success');
resultSet = result; resultSet = result;
expect(resultSet.getCount() == 10).assertTrue(); expect(resultSet.getCount() == 10).assertTrue();
...@@ -2795,8 +2822,8 @@ describe('SingleKvStorePromiseTest', function () { ...@@ -2795,8 +2822,8 @@ describe('SingleKvStorePromiseTest', function () {
it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800', 0, async function (done) { it('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800', 0, async function (done) {
console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800'); console.log('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800');
try { try {
let predicates = new dataShare.DataSharePredicates(); let query = new factory.Query();
await kvStore.getResultSet(predicates, async function (err, result) { await kvStore.getResultSet(query, async function (err, result) {
console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800 GetResultSet success: '+`, error code is ${err.code}, message is ${err.message}`); console.error('SUB_DDM_DKV_SINGLEKVSTORE_GETRESULTSET_PROMISE_0800 GetResultSet success: '+`, error code is ${err.code}, message is ${err.message}`);
kvStore.closeResultSet(result); kvStore.closeResultSet(result);
expect(err == undefined).assertTrue(); expect(err == undefined).assertTrue();
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* 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 '@ohos/hypium'
import factory from '@ohos.data.distributedData'; import factory from '@ohos.data.distributedData';
const TEST_BUNDLE_NAME = 'ohos.acts.kvStore'; const TEST_BUNDLE_NAME = 'ohos.acts.kvStore';
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* 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 '@ohos/hypium'
import dataPreferences from '@ohos.data.preferences' import dataPreferences from '@ohos.data.preferences'
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* 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 '@ohos/hypium'
import dataPreferences from '@ohos.data.preferences' import dataPreferences from '@ohos.data.preferences'
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* 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 '@ohos/hypium'
import dataPreferences from '@ohos.data.preferences' import dataPreferences from '@ohos.data.preferences'
import featureAbility from '@ohos.ability.featureAbility'; import featureAbility from '@ohos.ability.featureAbility';
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* 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 '@ohos/hypium'
import storage from '@system.storage'; import storage from '@system.storage';
const TAG = '[SYSTEM_STORAGE_JSKITS_TEST]' const TAG = '[SYSTEM_STORAGE_JSKITS_TEST]'
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* 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 '@ohos/hypium'
import dataRdb from '@ohos.data.rdb'; import dataRdb from '@ohos.data.rdb';
const TAG = "[RDB_JSKITS_TEST]" const TAG = "[RDB_JSKITS_TEST]"
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* 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 '@ohos/hypium'
import data_Rdb from '@ohos.data.relationalStore'; import data_Rdb from '@ohos.data.relationalStore';
import ability_featureAbility from '@ohos.ability.featureAbility' import ability_featureAbility from '@ohos.ability.featureAbility'
var context = ability_featureAbility.getContext(); var context = ability_featureAbility.getContext();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册