From 2111642378fcf7db76d2474dcf9448e053abb468 Mon Sep 17 00:00:00 2001 From: lixinyi Date: Fri, 25 Aug 2023 18:18:22 +0800 Subject: [PATCH] xts_acts_dstributeddatemgr1 Signed-off-by: lixinyi --- .../js/test/KvStoreBackupCallbackJsTest.js | 1272 +++++++++-------- .../js/test/KvStoreBackupPromiseJsTest.js | 1242 ++++++++-------- .../main/js/test/StoragePromiseJsunit.test.js | 4 +- .../main/js/test/RelationalStoreQuery.test.js | 201 +-- 4 files changed, 1368 insertions(+), 1351 deletions(-) diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvStoreBackupCallbackJsTest.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvStoreBackupCallbackJsTest.js index 19d0e74bc..0a49b34bf 100644 --- a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvStoreBackupCallbackJsTest.js +++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvStoreBackupCallbackJsTest.js @@ -12,7 +12,7 @@ * 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 distributedData from '@ohos.data.distributedKVStore'; import abilityFeatureAbility from '@ohos.ability.featureAbility' @@ -57,7 +57,7 @@ function publicCloseKvStore() { if (err) { console.info('Test closeKvStore err = ' + err); reject(err); - } + } console.info('Test closeKvStore data = ' + data); kvManager.deleteKVStore(BUNDLE_NAME, STORE_ID, (err, data) => { console.info('Test deleteKVStore begin') @@ -118,21 +118,25 @@ function publicBackup(kvStore,file){ function publicDeleteBackup(kvStore,files){ console.log(`Test deleteBackup ${JSON.stringify(files)}`) - return new Promise(function(resolve, reject) { - kvStore.deleteBackup(files, function(err, data){ - console.log("Test deleteBackup BackUpInfo =" + data); - if (err != undefined) { - console.log("Test deleteBackup err information: " + err ); - reject(err); - }else{ - var devices =new Array(); - devices = data; - delresult = devices; - console.log("Test deleteBackup pass "); - resolve(data); - } + try{ + return new Promise(function(resolve, reject) { + kvStore.deleteBackup(files, function(err, data){ + console.log("Test deleteBackup BackUpInfo =" + data); + if (err != undefined) { + console.log("Test deleteBackup err information: " + err ); + reject(err); + }else{ + var devices =new Array(); + devices = data; + delresult = devices; + console.log("Test deleteBackup pass "); + resolve(data); + } + }) }) - }) + } catch (e) { + console.log("111Test deleteBackup err information: " + e ); + } } function publicRestoreSp(kvStore,file){ @@ -179,663 +183,663 @@ var file = ''; var files =new Array(); export default function kvStoreBackupCallbackJsunittest(){ -describe('kvStoreBackupCallbackJsunittest', function () { - beforeAll( async function () { - console.info('Test beforeAll: Prerequisites at the test suite level, ' + - 'which are executed before t he test suite is executed.'); - await publicGetKvStore(optionLock); - console.info("Test kvstore = " + kvStore) - }) - beforeEach( async function () { - console.info('beforeEach: Prerequisites at the test case level,' + - ' which are executed before each test case is executed.'); - await publicGetKvStore(optionLock); - }) - afterEach( async function () { - console.info('afterEach: Test case-level clearance conditions, ' + - 'which are executed after each test case is executed.'); - await publicDeleteBackup(kvStore,files); - await publicCloseKvStore(); - files = [] - }) - afterAll(async function () { - console.info('afterAll: Test suite-level cleanup condition, ' + - 'which is executed after the test suite is executed'); - await publicCloseKvStore(); - kvManager = null; - console.info("Test kvstore = " + kvStore) - }) + describe('kvStoreBackupCallbackJsunittest', function () { + beforeAll( async function () { + console.info('Test beforeAll: Prerequisites at the test suite level, ' + + 'which are executed before t he test suite is executed.'); + await publicGetKvStore(optionLock); + console.info("Test kvstore = " + kvStore) + }) + beforeEach( async function () { + console.info('beforeEach: Prerequisites at the test case level,' + + ' which are executed before each test case is executed.'); + await publicGetKvStore(optionLock); + }) + afterEach( async function () { + console.info('afterEach: Test case-level clearance conditions, ' + + 'which are executed after each test case is executed.'); + await publicDeleteBackup(kvStore,files); + await publicCloseKvStore(); + files = [] + }) + afterAll(async function () { + console.info('afterAll: Test suite-level cleanup condition, ' + + 'which is executed after the test suite is executed'); + await publicCloseKvStore(); + kvManager = null; + console.info("Test kvstore = " + kvStore) + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100 - * @tc.desc Test Js Api SingleKvStore.restore() manal testcase 001 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100', 0, async function (done) { - try{ - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100 before restore"); - publicRestore(kvStore).then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100 going restore = " + JSON.stringify(data)); - expect().assertFail(); - done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100 Manualrestore fail 1" + err); - expect(err == "Error: Parameter error.The number of parameters is incorrect.").assertEqual(true); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100 + * @tc.desc Test Js Api SingleKvStore.restore() manal testcase 001 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100', 0, async function (done) { + try{ + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100 before restore"); + publicRestore(kvStore).then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100 going restore = " + JSON.stringify(data)); + expect().assertFail(); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100 Manualrestore fail 1" + err); + expect(err.code == 401 ).assertEqual(true); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100 Manualrestore fail 2" + JSON.stringify(e)); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0100 Manualrestore fail 2" + JSON.stringify(e)); - expect(e).assertFail(); - done(); - } - }) + } + }) - - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 - * @tc.desc Test Js Api SingleKvStore.restore() manal testcase 002 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 before getname"); - file = '123' ; - files[0] = file ; - publicBackup(kvStore,file) ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 before restore"); - await sleep(1000); - publicRestore(kvStore); - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 going restore "); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 publicDeleteBackup" + JSON.stringify(data)); - done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 fail 2" + e); - expect(e).assertFail(); - done(); - } - }) - - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 - * @tc.desc Test Js Api SingleKvStore.backup() db testcase 001 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 - */ - it('SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 before getname"); - file = 'true' ; - files[0] = file ; - console.log("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 before backup"); - publicBackup(kvStore,file) ; - console.log("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 going backup"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 + * @tc.desc Test Js Api SingleKvStore.restore() manal testcase 002 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 before getname"); + file = '123' ; + files[0] = file ; + publicBackup(kvStore,file) ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 before restore"); + await sleep(1000); + publicRestore(kvStore); + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 going restore "); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_CALLBACK_0200 fail 2" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 - * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 001 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100', 0, async function (done) { - try{ - console.log("KvStoreBackupestManalBackupCallbackTest001t before getname"); - files = [] - file = 'legal' ; - files[0] = "legal" ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 before backup"); - publicBackup(kvStore,file) ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 going backup"); - await sleep(1000); - await publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 publicDeleteBackup" + JSON.stringify(data)); - done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 export fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 - * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 002 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 before getname"); - file = '1' ; - files[0] = file ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 before backup"); - publicBackup(kvStore,file) ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 going backup"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 publicDeleteBackup" + JSON.stringify(data)); - done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 - * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 003 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 before getname"); - file = '1.0' ; - files[0] = file ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 before backup"); - publicBackup(kvStore,file) ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 going backup"); - await sleep(1000); - await publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 + * @tc.desc Test Js Api SingleKvStore.backup() db testcase 001 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 + */ + it('SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 before getname"); + file = 'true' ; + files[0] = file ; + console.log("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 before backup"); + publicBackup(kvStore,file) ; + console.log("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 going backup"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_BUCKUP_CALLBACK_0100 fail 2 " + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 - * @tc.desc Test Js Api SingleKvStore.backup() testcase 004 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 before getname"); - file = '' ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 before backup"); - await publicBackup(kvStore,file).then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 going backup"); - expect().assertFail(); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 + * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 001 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100', 0, async function (done) { + try{ + console.log("KvStoreBackupestManalBackupCallbackTest001t before getname"); + files = [] + file = 'legal' ; + files[0] = "legal" ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 before backup"); + publicBackup(kvStore,file) ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 going backup"); + await sleep(1000); + await publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0100 export fail 2 " + e); + expect(e).assertFail(); done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 ManualbackupCallback002 fail1 " + err); - expect(true).assertEqual(err.code == 401); + } + }) + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 + * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 002 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 before getname"); + file = '1' ; + files[0] = file ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 before backup"); + publicBackup(kvStore,file) ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 going backup"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0200 fail 2 " + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 - * @tc.desc Test Js Api SingleKvStore.backup() testcase 005 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 before getname"); - files = [] - var file = '1'; - var file1 = '2'; - var file2 = '3'; - var file3 = '4'; - var file4 = '5'; - files[0] = file ; - files[1] = file1 ; - files[2] = file2 ; - files[3] = file3 ; - files[4] = file4 ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 before backup"); - publicBackup(kvStore,file); - await sleep(500); - publicBackup(kvStore,file1); - await sleep(500); - publicBackup(kvStore,file2); - await sleep(500); - publicBackup(kvStore,file3); - await sleep(500); - publicBackup(kvStore,file4); - await sleep(500); - - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 before publicDeleteBackup"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - - expect("1").assertEqual(delresult[0][0]) - expect(0).assertEqual(delresult[0][1]); - - expect("2").assertEqual(delresult[1][0]) - expect(0).assertEqual(delresult[1][1]) - - expect("3").assertEqual(delresult[2][0]) - expect(0).assertEqual(delresult[2][1]) - - expect("4").assertEqual(delresult[3][0]) - expect(0).assertEqual(delresult[3][1]) - - expect("5").assertEqual(delresult[4][0]) - expect(27459591).assertEqual(delresult[4][1]) - - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 publicDeleteBackup" + JSON.stringify(data)); - files = []; - console.log("Test clear files"); - expect(data != null).assertTrue(); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 + * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 003 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 before getname"); + file = '1.0' ; + files[0] = file ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 before backup"); + publicBackup(kvStore,file) ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 going backup"); + await sleep(1000); + await publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0300 fail 2 " + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 - * @tc.desc Test Js Api SingleKvStore.backup() testcase 006 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 before getname"); - files = []; - var file = '1'; - var file1 = '2'; - var file2 = '3'; - var file3 = '4'; - var file4 = '5'; - var file5 = '6'; - files[0] = file ; - files[1] = file1 ; - files[2] = file2 ; - files[3] = file3 ; - files[4] = file4 ; - files[5] = file5 ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 before backup"); - publicBackup(kvStore,file); - await sleep(500); - publicBackup(kvStore,file1); - await sleep(500); - publicBackup(kvStore,file2); - await sleep(500); - publicBackup(kvStore,file3); - await sleep(500); - publicBackup(kvStore,file4); - await sleep(500); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 before Sixth backup"); - publicBackup(kvStore,file5).then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 going backup"); - expect(true).assertEqual(data == "code数字"); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 + * @tc.desc Test Js Api SingleKvStore.backup() testcase 004 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 before getname"); + file = '' ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 before backup"); + await publicBackup(kvStore,file).then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 going backup"); + expect().assertFail(); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 ManualbackupCallback002 fail1 " + err); + expect(true).assertEqual(err.code == 401); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0400 fail 2 " + e); + expect(e).assertFail(); done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 ManualbackupCallback002 fail1 " + err); - console.log(JSON.stringify(err)); - expect(true).assertEqual(JSON.stringify(err) == "{\"code\":\"\"}"); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 Sixth backup err"); - }) - await sleep(1000); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 before publicDeleteBackup"); - publicDeleteBackup(kvStore,files).then((data) => { - - expect("1").assertEqual(delresult[0][0]) - expect(0).assertEqual(delresult[0][1]); - - expect("5").assertEqual(delresult[4][0]) - expect(27459591).assertEqual(delresult[4][1]); - - expect("6").assertEqual(delresult[5][0]) - expect(27459591).assertEqual(delresult[5][1]); + } + }) - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 publicDeleteBackup" + JSON.stringify(data)); - files = []; - console.log("Test clear files"); - expect(data != null).assertTrue(); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 + * @tc.desc Test Js Api SingleKvStore.backup() testcase 005 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 before getname"); + files = [] + var file = '1'; + var file1 = '2'; + var file2 = '3'; + var file3 = '4'; + var file4 = '5'; + files[0] = file ; + files[1] = file1 ; + files[2] = file2 ; + files[3] = file3 ; + files[4] = file4 ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 before backup"); + publicBackup(kvStore,file); + await sleep(500); + publicBackup(kvStore,file1); + await sleep(500); + publicBackup(kvStore,file2); + await sleep(500); + publicBackup(kvStore,file3); + await sleep(500); + publicBackup(kvStore,file4); + await sleep(500); + + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 before publicDeleteBackup"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + + expect("1").assertEqual(delresult[0][0]) + expect(0).assertEqual(delresult[0][1]); + + expect("2").assertEqual(delresult[1][0]) + expect(0).assertEqual(delresult[1][1]) + + expect("3").assertEqual(delresult[2][0]) + expect(0).assertEqual(delresult[2][1]) + + expect("4").assertEqual(delresult[3][0]) + expect(0).assertEqual(delresult[3][1]) + + expect("5").assertEqual(delresult[4][0]) + expect(27459591).assertEqual(delresult[4][1]) + + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 publicDeleteBackup" + JSON.stringify(data)); + files = []; + console.log("Test clear files"); + expect(data != null).assertTrue(); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0500 fail 2 " + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 - * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 001 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 - */ - it('SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 before getname"); - file = 'legal' ; - files[0] = file ; - publicBackup(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 before restoresp"); - await sleep(1000); - publicRestoreSp(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 going restoresp"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 + * @tc.desc Test Js Api SingleKvStore.backup() testcase 006 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 before getname"); + files = []; + var file = '1'; + var file1 = '2'; + var file2 = '3'; + var file3 = '4'; + var file4 = '5'; + var file5 = '6'; + files[0] = file ; + files[1] = file1 ; + files[2] = file2 ; + files[3] = file3 ; + files[4] = file4 ; + files[5] = file5 ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 before backup"); + publicBackup(kvStore,file); + await sleep(500); + publicBackup(kvStore,file1); + await sleep(500); + publicBackup(kvStore,file2); + await sleep(500); + publicBackup(kvStore,file3); + await sleep(500); + publicBackup(kvStore,file4); + await sleep(500); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 before Sixth backup"); + publicBackup(kvStore,file5).then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 going backup"); + expect(true).assertEqual(data == "code数字"); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 ManualbackupCallback002 fail1 " + err); + console.log(JSON.stringify(err)); + expect(true).assertEqual(JSON.stringify(err) == "{\"code\":\"\"}"); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 Sixth backup err"); + }) + await sleep(1000); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 before publicDeleteBackup"); + publicDeleteBackup(kvStore,files).then((data) => { + + expect("1").assertEqual(delresult[0][0]) + expect(0).assertEqual(delresult[0][1]); + + expect("5").assertEqual(delresult[4][0]) + expect(27459591).assertEqual(delresult[4][1]); + + expect("6").assertEqual(delresult[5][0]) + expect(27459591).assertEqual(delresult[5][1]); + + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 publicDeleteBackup" + JSON.stringify(data)); + files = []; + console.log("Test clear files"); + expect(data != null).assertTrue(); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_CALLBACK_0600 fail 2 " + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 - * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 002 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 - */ - it('SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 before getname"); - file = 'true' ; - files[0] = file ; - publicBackup(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 before restoresp"); - await sleep(1000); - publicRestoreSp(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 going restoresp"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 + * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 001 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 + */ + it('SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 before getname"); + file = 'legal' ; + files[0] = file ; + publicBackup(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 before restoresp"); + await sleep(1000); + publicRestoreSp(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 going restoresp"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0100 fail 2" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 - * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 003 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 - */ - it('SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 before getname"); - file = '1' ; - files[0] = file ; - publicBackup(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 before restoresp"); - await sleep(1000); - publicRestoreSp(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 going restoresp"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 + * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 002 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 + */ + it('SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 before getname"); + file = 'true' ; + files[0] = file ; + publicBackup(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 before restoresp"); + await sleep(1000); + publicRestoreSp(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 going restoresp"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0200 fail 2" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 - * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 004 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 - */ - it('SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 before getname"); - file = '1.0' ; - files[0] = file ; - publicBackup(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 before restoresp"); - await sleep(1000); - publicRestoreSp(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 going restoresp"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 + * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 003 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 + */ + it('SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 before getname"); + file = '1' ; + files[0] = file ; + publicBackup(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 before restoresp"); + await sleep(1000); + publicRestoreSp(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 going restoresp"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0300 fail 2" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 - * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 005 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 - */ - it('SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 before getname"); - file = '' ; - publicBackup(kvStore,file) ; - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 before restoresp"); - await sleep(1000); - publicRestoreSp(kvStore,file).then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 going restoresp = " + JSON.stringify(data)); - expect(true).assertEqual(false); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 + * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 004 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 + */ + it('SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 before getname"); + file = '1.0' ; + files[0] = file ; + publicBackup(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 before restoresp"); + await sleep(1000); + publicRestoreSp(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 going restoresp"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0400 fail 2" + e); + expect(e).assertFail(); done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 fail 1" + err); - expect(true).assertEqual(err.code == 401); - done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 - * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 006 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 - */ - it('SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 before getname"); - file = 'legal' ; - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 before restoresp"); - publicRestoreSp(kvStore,file).then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 going restoresp = " + JSON.stringify(data)); - expect(true).assertEqual(false); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 + * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 005 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 + */ + it('SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 before getname"); + file = '' ; + publicBackup(kvStore,file) ; + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 before restoresp"); + await sleep(1000); + publicRestoreSp(kvStore,file).then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 going restoresp = " + JSON.stringify(data)); + expect(true).assertEqual(false); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 fail 1" + err); + expect(true).assertEqual(err.code == 401); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0500 fail 2" + e); + expect(e).assertFail(); done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 fail 1" + err); - expect(true).assertEqual(err.code == 401); - done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 - * @tc.desc Test Js Api SingleKvStore.deleteBackup() testcase 001 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 - */ - it('SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 before deleteBackup"); - file = '123' ; - files[0] = file ; - await publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 delResult[1] = " + delResult[1]); - expect(27459591).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 + * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 006 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 + */ + it('SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 before getname"); + file = 'legal' ; + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 before restoresp"); + publicRestoreSp(kvStore,file).then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 going restoresp = " + JSON.stringify(data)); + expect(true).assertEqual(false); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 fail 1" + err); + expect(true).assertEqual(err.code == 401); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORETOSPECIFIEDVERSION_CALLBACK_0600 fail 2" + e); + expect(e).assertFail(); done(); - }) - console.log("SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 going deleteBackup"); - } catch (err) { - console.log("SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 fail 2" + err); - expect(err).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 - * @tc.desc Test Js Api SingleKvStore.put() db testcase 001 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 - */ - it('SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 before putdata"); - publicPut(kvStore,"key","value").then((data)=>{ - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 going putdata data= " + JSON.stringify(data)); - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 going putdata"); - expect(data == undefined).assertTrue(); - done(); - }).catch((err)=>{ - console.log("UB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 fail 1 " + JSON.stringify(err)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 + * @tc.desc Test Js Api SingleKvStore.deleteBackup() testcase 001 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 + */ + it('SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 before deleteBackup"); + file = '123' ; + files[0] = file ; + await publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 delResult[1] = " + delResult[1]); + expect(27459591).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + console.log("SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 going deleteBackup"); + } catch (err) { + console.log("SUB_DDM_DKV_KVBACKUP_DELETEBUCKUP_CALLBACK_0100 fail 2" + err); expect(err).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 Backupinfo fail" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 - * @tc.desc Test Js Api SingleKvStore.put() db testcase 002 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 - */ - it('SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 before putdata"); - await publicPut(kvStore,"key","value") ; - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 going putdata"); - publicGet(kvStore,"key").then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 going getdata" + JSON.stringify(data)); - expect(true).assertEqual(data == "value"); - done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 Get fail 1 " + JSON.stringify(err)); - expect(err).assertFail(); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 + * @tc.desc Test Js Api SingleKvStore.put() db testcase 001 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 + */ + it('SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 before putdata"); + publicPut(kvStore,"key","value").then((data)=>{ + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 going putdata data= " + JSON.stringify(data)); + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 going putdata"); + expect(data == undefined).assertTrue(); + done(); + }).catch((err)=>{ + console.log("UB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 fail 1 " + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0100 Backupinfo fail" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 Get fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 - * @tc.desc Test Js Api SingleKvStore.put() db testcase 003 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 - */ - it('SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 before putdata"); - await publicPut(kvStore,"putcallback003","value1") ; - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 going putdata"); - publicGet(kvStore,"putcallback").then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 going getdata" + JSON.stringify(data)); - expect(true).assertEqual(false); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 + * @tc.desc Test Js Api SingleKvStore.put() db testcase 002 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 + */ + it('SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 before putdata"); + await publicPut(kvStore,"key","value") ; + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 going putdata"); + publicGet(kvStore,"key").then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 going getdata" + JSON.stringify(data)); + expect(true).assertEqual(data == "value"); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 Get fail 1 " + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0200 Get fail 2" + e); + expect(e).assertFail(); done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 Get fail 1 " + JSON.stringify(err)); - expect(err.code).assertEqual("15100004"); + } + }) + + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 + * @tc.desc Test Js Api SingleKvStore.put() db testcase 003 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 + */ + it('SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 before putdata"); + await publicPut(kvStore,"putcallback003","value1") ; + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 going putdata"); + publicGet(kvStore,"putcallback").then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 going getdata" + JSON.stringify(data)); + expect(true).assertEqual(false); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 Get fail 1 " + JSON.stringify(err)); + expect(err.code).assertEqual("15100004"); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 Get fail 2" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_CALLBACK_0300 Get fail 2" + e); - expect(e).assertFail(); - done(); - } + } + }) }) -}) } \ No newline at end of file diff --git a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvStoreBackupPromiseJsTest.js b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvStoreBackupPromiseJsTest.js index cc24460ae..dad23b7cb 100644 --- a/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvStoreBackupPromiseJsTest.js +++ b/distributeddatamgr/distributedKVStoretest/distributedKVStorejstest/hap/src/main/js/test/KvStoreBackupPromiseJsTest.js @@ -111,21 +111,27 @@ function publicBackup(kvStore,file){ }) } -function publicDeleteBackup(kvStore,files) { +function publicDeleteBackup(kvStore,files){ console.log(`Test deleteBackup ${JSON.stringify(files)}`) - return new Promise(function (resolve, reject) { - kvStore.deleteBackup(files).then((data) => { - console.log("Test deleteBackup BackUpInfo =" + data); - var devices = new Array(); - devices = data; - delresult = devices; - console.log("Test deleteBackup pass "); - resolve(data); - }).catch((err) => { - console.log("test deleteBackup err information: " + err); - reject(err); + try{ + return new Promise(function(resolve, reject) { + kvStore.deleteBackup(files, function(err, data){ + console.log("Test deleteBackup BackUpInfo =" + data); + if (err != undefined) { + console.log("Test deleteBackup err information: " + err ); + reject(err); + }else{ + var devices =new Array(); + devices = data; + delresult = devices; + console.log("Test deleteBackup pass "); + resolve(data); + } + }) }) - }) + } catch (e) { + console.log("111Test deleteBackup err information: " + e ); + } } function publicRestoreSp(kvStore,file){ @@ -170,649 +176,649 @@ var file = ''; var files =new Array(); export default function kvStoreBackupPromiseJsunittest(){ -describe('kvStoreBackupPromiseJsunittest', function () { - beforeAll( async function () { - console.info('Test beforeAll: Prerequisites at the test suite level, ' + - 'which are executed before the test suite is executed.'); - await publicGetKvStore(optionLock); - console.info("Test kvstore = " + kvStore) - }) - beforeEach(function () { - console.info('beforeEach: Prerequisites at the test case level,' + - ' which are executed before each test case is executed.'); - }) - afterEach( async function () { - console.info('afterEach: Test case-level clearance conditions, ' + - 'which are executed after each test case is executed.'); - await publicDeleteBackup(kvStore,files); - }) - afterAll( async function () { - console.info('afterAll: Test suite-level cleanup condition, ' + - 'which is executed after the test suite is executed'); - await publicCloseKvStore(); - kvManager = null; - console.info("Test kvstore = " + kvStore) - }) - - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100 - * @tc.desc Test Js Api SingleKvStore.restore() manal testcase 001 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100 before restore"); - - - publicRestore(kvStore).then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100 going restore = " + JSON.stringify(data)); - expect(true).assertEqual(data == 'code数字'); - done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100 Manualrestore fail 1" + err); - expect(true).assertEqual(JSON.stringify(err) == '{}'); - done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100 Manualrestore fail 2" + JSON.stringify(e)); - expect(e).assertFail(); - done(); - } - }) + describe('kvStoreBackupPromiseJsunittest', function () { + beforeAll( async function () { + console.info('Test beforeAll: Prerequisites at the test suite level, ' + + 'which are executed before the test suite is executed.'); + await publicGetKvStore(optionLock); + console.info("Test kvstore = " + kvStore) + }) + beforeEach(function () { + console.info('beforeEach: Prerequisites at the test case level,' + + ' which are executed before each test case is executed.'); + }) + afterEach( async function () { + console.info('afterEach: Test case-level clearance conditions, ' + + 'which are executed after each test case is executed.'); + await publicDeleteBackup(kvStore,files); + }) + afterAll( async function () { + console.info('afterAll: Test suite-level cleanup condition, ' + + 'which is executed after the test suite is executed'); + await publicCloseKvStore(); + kvManager = null; + console.info("Test kvstore = " + kvStore) + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 - * @tc.desc Test Js Api SingleKvStore.restore() manal testcase 002 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 before getname"); - file = '123' ; - files[0] = file ; - publicBackup(kvStore,file) ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 before restore"); - await sleep(1000); - publicRestore(kvStore); - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 going restore "); - await sleep(1000); - await publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100 + * @tc.desc Test Js Api SingleKvStore.restore() manal testcase 001 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100 before restore"); + + + publicRestore(kvStore).then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100 going restore = " + JSON.stringify(data)); + expect(true).assertEqual(data == 'code数字'); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100 Manualrestore fail 1" + err); + expect(true).assertEqual(JSON.stringify(err) == '{}'); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0100 Manualrestore fail 2" + JSON.stringify(e)); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 Manualrestore fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 - * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 001 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 before getname"); - file = 'legal' ; - files[0] = "legal" ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 before backup"); - publicBackup(kvStore,file) ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 going backup"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 + * @tc.desc Test Js Api SingleKvStore.restore() manal testcase 002 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 before getname"); + file = '123' ; + files[0] = file ; + publicBackup(kvStore,file) ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 before restore"); + await sleep(1000); + publicRestore(kvStore); + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 going restore "); + await sleep(1000); + await publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALRESTORE_PROMISE_0200 Manualrestore fail 2" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 export fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 - * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 002 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 before getname"); - file = 'true' ; - files[0] = file ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 before backup"); - publicBackup(kvStore,file) ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 going backup"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 + * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 001 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 before getname"); + file = 'legal' ; + files[0] = "legal" ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 before backup"); + publicBackup(kvStore,file) ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 going backup"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0100 export fail 2 " + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 - * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 003 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 before getname"); - file = '1' ; - files[0] = file ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 before backup"); - publicBackup(kvStore,file) ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 going backup"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 + * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 002 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 before getname"); + file = 'true' ; + files[0] = file ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 before backup"); + publicBackup(kvStore,file) ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 going backup"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0200 fail 2 " + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 - * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 004 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 before getname"); - file = '1.0' ; - files[0] = file ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 before backup"); - publicBackup(kvStore,file) ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 going backup"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 + * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 003 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 before getname"); + file = '1' ; + files[0] = file ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 before backup"); + publicBackup(kvStore,file) ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 going backup"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0300 fail 2 " + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 - * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 005 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 before getname"); - file = '' ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 before backup"); - publicBackup(kvStore,file).then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 going backup"); - expect(true).assertEqual(data == "code数字"); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 + * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 004 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 before getname"); + file = '1.0' ; + files[0] = file ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 before backup"); + publicBackup(kvStore,file) ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 going backup"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0400 fail 2 " + e); + expect(e).assertFail(); done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 fail1 " + err); - console.log(JSON.stringify(err)); - expect(true).assertEqual(err.code == 401) - done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 - * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 006 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 before getname"); - file = '1' ; - var file1 = '2'; - var file2 = '3'; - var file3 = '4'; - var file4 = '5'; - files[0] = file ; - files[1] = file1 ; - files[2] = file2 ; - files[3] = file3 ; - files[4] = file4 ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 before backup"); - publicBackup(kvStore,file); - await sleep(500); - publicBackup(kvStore,file1); - await sleep(500); - publicBackup(kvStore,file2); - await sleep(500); - publicBackup(kvStore,file3); - await sleep(500); - publicBackup(kvStore,file4); - await sleep(500); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 before publicDeleteBackup"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - - expect("1").assertEqual(delresult[0][0]) - expect(0).assertEqual(delresult[0][1]); - - expect("2").assertEqual(delresult[1][0]) - expect(0).assertEqual(delresult[1][1]) - - expect("3").assertEqual(delresult[2][0]) - expect(0).assertEqual(delresult[2][1]) - - expect("4").assertEqual(delresult[3][0]) - expect(0).assertEqual(delresult[3][1]) - - expect("5").assertEqual(delresult[4][0]) - expect(27459591).assertEqual(delresult[4][1]) - - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 + * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 005 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 before getname"); + file = '' ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 before backup"); + publicBackup(kvStore,file).then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 going backup"); + expect(true).assertEqual(data == "code数字"); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 fail1 " + err); + console.log(JSON.stringify(err)); + expect(true).assertEqual(err.code == 401) + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0500 fail 2 " + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 - * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 007 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 - */ - it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 before getname"); - files = []; - var file = '1'; - var file1 = '2'; - var file2 = '3'; - var file3 = '4'; - var file4 = '5'; - var file5 = '6'; - files[0] = file ; - files[1] = file1 ; - files[2] = file2 ; - files[3] = file3 ; - files[4] = file4 ; - files[5] = file5 ; - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 before backup"); - publicBackup(kvStore,file); - await sleep(500); - publicBackup(kvStore,file1); - await sleep(500); - publicBackup(kvStore,file2); - await sleep(500); - publicBackup(kvStore,file3); - await sleep(500); - publicBackup(kvStore,file4); - await sleep(500); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 before Sixth backup"); - publicBackup(kvStore,file5).then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 going backup"); - expect(true).assertEqual(data == "code数字"); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 + * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 006 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 before getname"); + file = '1' ; + var file1 = '2'; + var file2 = '3'; + var file3 = '4'; + var file4 = '5'; + files[0] = file ; + files[1] = file1 ; + files[2] = file2 ; + files[3] = file3 ; + files[4] = file4 ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 before backup"); + publicBackup(kvStore,file); + await sleep(500); + publicBackup(kvStore,file1); + await sleep(500); + publicBackup(kvStore,file2); + await sleep(500); + publicBackup(kvStore,file3); + await sleep(500); + publicBackup(kvStore,file4); + await sleep(500); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 before publicDeleteBackup"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + + expect("1").assertEqual(delresult[0][0]) + expect(0).assertEqual(delresult[0][1]); + + expect("2").assertEqual(delresult[1][0]) + expect(0).assertEqual(delresult[1][1]) + + expect("3").assertEqual(delresult[2][0]) + expect(0).assertEqual(delresult[2][1]) + + expect("4").assertEqual(delresult[3][0]) + expect(0).assertEqual(delresult[3][1]) + + expect("5").assertEqual(delresult[4][0]) + expect(27459591).assertEqual(delresult[4][1]) + + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0600 fail 2 " + e); + expect(e).assertFail(); done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 fail1 " + err); - console.log("err is " + JSON.stringify(err) + "code is " + err.code); - expect(true).assertEqual(JSON.stringify(err) == "{\"code\":\"\"}"); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 Sixth backup err"); - }) - await sleep(1000); - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 before publicDeleteBackup"); - publicDeleteBackup(kvStore,files).then((data) => { - - expect("1").assertEqual(delresult[0][0]) - console.log(delresult[0][0]); - console.log(delresult[0][1]); - expect(0).assertEqual(delresult[0][1]); - - expect("5").assertEqual(delresult[4][0]) - expect(27459591).assertEqual(delresult[4][1]); - - expect("6").assertEqual(delresult[5][0]) - expect(27459591).assertEqual(delresult[5][1]); + } + }) - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 + * @tc.desc Test Js Api SingleKvStore.backup() manal testcase 007 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 + */ + it('SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 before getname"); + files = []; + var file = '1'; + var file1 = '2'; + var file2 = '3'; + var file3 = '4'; + var file4 = '5'; + var file5 = '6'; + files[0] = file ; + files[1] = file1 ; + files[2] = file2 ; + files[3] = file3 ; + files[4] = file4 ; + files[5] = file5 ; + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 before backup"); + publicBackup(kvStore,file); + await sleep(500); + publicBackup(kvStore,file1); + await sleep(500); + publicBackup(kvStore,file2); + await sleep(500); + publicBackup(kvStore,file3); + await sleep(500); + publicBackup(kvStore,file4); + await sleep(500); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 before Sixth backup"); + publicBackup(kvStore,file5).then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 going backup"); + expect(true).assertEqual(data == "code数字"); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 fail1 " + err); + console.log("err is " + JSON.stringify(err) + "code is " + err.code); + expect(true).assertEqual(JSON.stringify(err) == "{\"code\":\"\"}"); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 Sixth backup err"); + }) + await sleep(1000); + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 before publicDeleteBackup"); + publicDeleteBackup(kvStore,files).then((data) => { + + expect("1").assertEqual(delresult[0][0]) + console.log(delresult[0][0]); + console.log(delresult[0][1]); + expect(0).assertEqual(delresult[0][1]); + + expect("5").assertEqual(delresult[4][0]) + expect(27459591).assertEqual(delresult[4][1]); + + expect("6").assertEqual(delresult[5][0]) + expect(27459591).assertEqual(delresult[5][1]); + + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 fail 2 " + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_MANALBACKUP_PROMISE_0700 fail 2 " + e); - expect(e).assertFail(); - done(); - } - }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 - * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 001 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 - */ - it('SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 before getname"); - file = 'legal' ; - files[0] = file ; - publicBackup(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 before restoresp"); - await sleep(1000); - publicRestoreSp(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 going restoresp"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[5]; - console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 publicDeleteBackup" + JSON.stringify(data)); + } + }) + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 + * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 001 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 + */ + it('SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 before getname"); + file = 'legal' ; + files[0] = file ; + publicBackup(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 before restoresp"); + await sleep(1000); + publicRestoreSp(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 going restoresp"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[5]; + console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 Manualrestoresp fail 2" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0100 Manualrestoresp fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 - * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 002 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 - */ - it('SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 before getname"); - file = 'true' ; - files[0] = file ; - publicBackup(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 before restoresp"); - await sleep(1000); - publicRestoreSp(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 going restoresp"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[5]; - console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 + * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 002 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 + */ + it('SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 before getname"); + file = 'true' ; + files[0] = file ; + publicBackup(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 before restoresp"); + await sleep(1000); + publicRestoreSp(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 going restoresp"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[5]; + console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 fail 2" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0200 fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 - * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 003 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 - */ - it('SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 before getname"); - file = '1' ; - files[0] = file ; - publicBackup(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 before restoresp"); - await sleep(1000); - publicRestoreSp(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 going restoresp"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 + * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 003 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 + */ + it('SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 before getname"); + file = '1' ; + files[0] = file ; + publicBackup(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 before restoresp"); + await sleep(1000); + publicRestoreSp(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 going restoresp"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 fail 2" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0300 fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 - * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 004 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 - */ - it('SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 before getname"); - file = '1.0' ; - files[0] = file ; - publicBackup(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 before restoresp"); - await sleep(1000); - publicRestoreSp(kvStore,file); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 going restoresp"); - await sleep(1000); - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 delResult[1] = " + delResult[1]); - expect(0).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 + * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 004 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 + */ + it('SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 before getname"); + file = '1.0' ; + files[0] = file ; + publicBackup(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 before restoresp"); + await sleep(1000); + publicRestoreSp(kvStore,file); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 going restoresp"); + await sleep(1000); + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 delResult[1] = " + delResult[1]); + expect(0).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 Manualrestoresp fail 2" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0400 Manualrestoresp fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 - * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 005 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 - */ - it('SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 before getname"); - file = '' ; - publicBackup(kvStore,file) ; - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 before restoresp"); - await sleep(1000); - publicRestoreSp(kvStore,file).then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 going restoresp = " + JSON.stringify(data)); - expect(true).assertEqual(false); - done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 Manualrestoresp fail 1" + err); - expect(true).assertEqual(err.code == 401); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 + * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 005 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 + */ + it('SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 before getname"); + file = '' ; + publicBackup(kvStore,file) ; + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 before restoresp"); + await sleep(1000); + publicRestoreSp(kvStore,file).then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 going restoresp = " + JSON.stringify(data)); + expect(true).assertEqual(false); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 Manualrestoresp fail 1" + err); + expect(true).assertEqual(err.code == 401); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 Manualrestoresp fail 2" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0500 Manualrestoresp fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 - * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 006 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 - */ - it('SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 before getname"); - file = 'legal' ; - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 before restoresp"); - publicRestoreSp(kvStore,file).then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 going restoresp = " + JSON.stringify(data)); - expect(true).assertEqual(false); - done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 Manualrestoresp fail 1" + err); - expect(true).assertEqual(err.code == 401); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 + * @tc.desc Test Js Api SingleKvStore.restore() SpecifiedVerision testcase 006 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 + */ + it('SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 before getname"); + file = 'legal' ; + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 before restoresp"); + publicRestoreSp(kvStore,file).then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 going restoresp = " + JSON.stringify(data)); + expect(true).assertEqual(false); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 Manualrestoresp fail 1" + err); + expect(true).assertEqual(err.code == 401); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 Manualrestoresp fail 2" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_RESTORESPECIFIEDVERSION_PROMISE_0600 Manualrestoresp fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 - * @tc.desc Test Js Api SingleKvStore.deleteBackup() testcase 001 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 - */ - it('SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 before deleteBackup"); - file = '123' ; - files[0] = file ; - publicDeleteBackup(kvStore,files).then((data) => { - let delResult = delresult[0]; - console.info("SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 delResult = " + delResult); - console.info("SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 delResult[1] = " + delResult[1]); - expect(27459591).assertEqual(delResult[1]); - console.log("SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 publicDeleteBackup" + JSON.stringify(data)); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 + * @tc.desc Test Js Api SingleKvStore.deleteBackup() testcase 001 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 + */ + it('SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 before deleteBackup"); + file = '123' ; + files[0] = file ; + publicDeleteBackup(kvStore,files).then((data) => { + let delResult = delresult[0]; + console.info("SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 delResult = " + delResult); + console.info("SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 delResult[1] = " + delResult[1]); + expect(27459591).assertEqual(delResult[1]); + console.log("SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 publicDeleteBackup" + JSON.stringify(data)); + done(); + }) + console.log("SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 going deleteBackup"); + } catch (err) { + console.log("SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 deleteBackup fail 2" + err); + expect(err).assertFail(); done(); - }) - console.log("SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 going deleteBackup"); - } catch (err) { - console.log("SUB_DDM_DKV_KVBACKUP_DELETEBACKUP_PROMISE_0100 deleteBackup fail 2" + err); - expect(err).assertFail(); - done(); - } - }) - - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0100 - * @tc.desc Test Js Api SingleKvStore.put() db testcase 001 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0100 - */ - it('SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0100', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0100 before putdata"); - publicPut(kvStore,"key1","value1") ; - console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0100 going putdata"); - done(); - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0100 Backupinfo fail" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 - * @tc.desc Test Js Api SingleKvStore.put() db testcase 002 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 - */ - it('SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 before putdata"); - await publicPut(kvStore,"PutPromise0002","value") ; - console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 going putdata"); - publicGet(kvStore,"PutPromise0002").then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 going getdata" + JSON.stringify(data)); - expect(true).assertEqual(data == "value"); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0100 + * @tc.desc Test Js Api SingleKvStore.put() db testcase 001 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0100 + */ + it('SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0100', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0100 before putdata"); + publicPut(kvStore,"key1","value1") ; + console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0100 going putdata"); done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 Get fail 1 " + JSON.stringify(err)); - expect(err).assertFail(); + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0100 Backupinfo fail" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 Get fail 2" + e); - expect(e).assertFail(); - done(); - } - }) + } + }) - /** - * @tc.name SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300 - * @tc.desc Test Js Api SingleKvStore.put() db testcase 003 - * @tc.type: FUNC - * @tc.number: SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300 - */ - it('SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300', 0, async function (done) { - try { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300 before putdata"); - await publicPut(kvStore,"PutPromise0004","value1") ; - console.log("KvStoreBackupestDbBuckupPutPromiseTest004t going putdata"); - publicGet(kvStore,"PutPromise").then((data) => { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300 going getdata" + JSON.stringify(data)); - expect(true).assertEqual(JSON.stringify(data) == '{}'); + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 + * @tc.desc Test Js Api SingleKvStore.put() db testcase 002 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 + */ + it('SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 before putdata"); + await publicPut(kvStore,"PutPromise0002","value") ; + console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 going putdata"); + publicGet(kvStore,"PutPromise0002").then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 going getdata" + JSON.stringify(data)); + expect(true).assertEqual(data == "value"); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 Get fail 1 " + JSON.stringify(err)); + expect(err).assertFail(); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0200 Get fail 2" + e); + expect(e).assertFail(); done(); - }).catch((err) => { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300 Get fail 1 " + JSON.stringify(err)); - console.log(JSON.stringify(err)); - expect(true).assertEqual(err.code == 15100004); + } + }) + + /** + * @tc.name SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300 + * @tc.desc Test Js Api SingleKvStore.put() db testcase 003 + * @tc.type: FUNC + * @tc.number: SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300 + */ + it('SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300', 0, async function (done) { + try { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300 before putdata"); + await publicPut(kvStore,"PutPromise0004","value1") ; + console.log("KvStoreBackupestDbBuckupPutPromiseTest004t going putdata"); + publicGet(kvStore,"PutPromise").then((data) => { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300 going getdata" + JSON.stringify(data)); + expect(true).assertEqual(JSON.stringify(data) == '{}'); + done(); + }).catch((err) => { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300 Get fail 1 " + JSON.stringify(err)); + console.log(JSON.stringify(err)); + expect(true).assertEqual(err.code == 15100004); + done(); + }) + } catch (e) { + console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300 Get fail 2" + e); + expect(e).assertFail(); done(); - }) - } catch (e) { - console.log("SUB_DDM_DKV_KVBACKUP_PUT_PROMISE_0300 Get fail 2" + e); - expect(e).assertFail(); - done(); - } + } + }) }) -}) } \ No newline at end of file diff --git a/distributeddatamgr/preferencesjstest/hap/src/main/js/test/StoragePromiseJsunit.test.js b/distributeddatamgr/preferencesjstest/hap/src/main/js/test/StoragePromiseJsunit.test.js index 5d86f6b5c..b88dc508a 100644 --- a/distributeddatamgr/preferencesjstest/hap/src/main/js/test/StoragePromiseJsunit.test.js +++ b/distributeddatamgr/preferencesjstest/hap/src/main/js/test/StoragePromiseJsunit.test.js @@ -26,8 +26,8 @@ const MAX_VALUE_LENGTH = 'y'.repeat(8192) var mPref; export default function storagePromiseTest() { -describe('storagePromiseTest', function (done) { - beforeAll(async function () { +describe('storagePromiseTest', function () { + beforeAll(async function (done) { console.info('beforeAll') const promise = storage.getStorage(PATH); promise.then((Storage)=>{ diff --git a/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreQuery.test.js b/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreQuery.test.js index e6a55652b..af77241ff 100644 --- a/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreQuery.test.js +++ b/distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreQuery.test.js @@ -19,7 +19,7 @@ import ability_featureAbility from '@ohos.ability.featureAbility'; const TAG = "[RelationalStore_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)" ++ "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)" const STORE_CONFIG = { name: "Query.db", securityLevel: data_Rdb.SecurityLevel.S1 @@ -64,11 +64,11 @@ async function CreatRdbStore(context, STORE_CONFIG) { } await RdbStore.insert("test", valueBucket) } - return RdbStore + } async function getLocalDeviceId(){ - + } export default function relationalStoreQueryTest(){ describe("relationalStoreQueryTest", function() { @@ -81,7 +81,7 @@ export default function relationalStoreQueryTest(){ context:context } } - + const options = { createIfMissing : true, encrypt : false, @@ -91,44 +91,44 @@ export default function relationalStoreQueryTest(){ schema : '', securityLevel : factory.SecurityLevel.S2, } - + console.info('getLocalDeviceId config:'+ JSON.stringify(config)); - await factory.createKVManager(config).then((manager) => { - kvManager = manager; - console.info('getLocalDeviceId createKVManager success'); - }).catch((err) => { - console.info('getLocalDeviceId createKVManager err ' + err); - }); - await kvManager.getKVStore(TEST_STORE_ID, options).then((store) => { - kvStore = store; - console.info('getLocalDeviceId getKVStore for getDeviceId success'); - }).catch((err) => { - console.info('getLocalDeviceId getKVStore err ' + err); - }); - var getDeviceId = new Promise((resolve, reject) => { - kvStore.on('dataChange', 0, function (data) { - console.info('getLocalDeviceId on data change: ' + JSON.stringify(data)); - 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 factory.createKVManager(config).then((manager) => { + kvManager = manager; + console.info('getLocalDeviceId createKVManager success'); + }).catch((err) => { + console.info('getLocalDeviceId createKVManager err ' + err); + }); + await kvManager.getKVStore(TEST_STORE_ID, options).then((store) => { + kvStore = store; + console.info('getLocalDeviceId getKVStore for getDeviceId success'); + }).catch((err) => { + console.info('getLocalDeviceId getKVStore err ' + err); + }); + var getDeviceId = new Promise((resolve, reject) => { + kvStore.on('dataChange', 0, function (data) { + console.info('getLocalDeviceId on data change: ' + JSON.stringify(data)); + resolve(data.deviceId); }); - 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(); + kvStore.put("getDeviceId", "byPut").then((data) => { + console.info('getLocalDeviceId put success'); + expect(data == undefined).assertTrue(); }); - 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'); + setTimeout(() => { + reject(new Error('not resolved in 2 second, reject it.')) + }, 2000); + }); + 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() console.info(TAG + 'beforeAll') done(); @@ -136,7 +136,7 @@ export default function relationalStoreQueryTest(){ beforeEach(async function () { console.info(TAG + 'beforeEach') - + rdbStore = await CreatRdbStore(context, STORE_CONFIG) }) @@ -150,31 +150,38 @@ export default function relationalStoreQueryTest(){ }) /** - * @tc.name RelationalStore remotequery test - * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0010 - * @tc.desc RelationalStore remotequery function test - */ - it('RdbRemoteQueryPromiseTest0010', 0, async function (done){ + * @tc.name RelationalStore remotequery test + * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0010 + * @tc.desc RelationalStore remotequery function test + */ + + it('RdbRemoteQueryPromiseTest0010', 0, async function (done){ console.info(TAG + "RdbRemoteQueryPromiseTest0010 start") - let errInfo = undefined let predicates = new data_Rdb.RdbPredicates("test"); predicates.equalTo("name", "zhangsan") 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){ - 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") }) - /** - * @tc.name RelationalStore remotequery test - * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0020 - * @tc.desc RelationalStore remotequery function test - */ - it('RdbRemoteQueryPromiseTest0020', 0, async function (done){ + * @tc.name RelationalStore remotequery test + * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0020 + * @tc.desc RelationalStore remotequery function test + */ + it('RdbRemoteQueryPromiseTest0020', 0, async function (done){ console.info(TAG + "RdbRemoteQueryPromiseTest0020 start") let predicates = new data_Rdb.RdbPredicates("test"); predicates.equalTo("name", "zhangsan") @@ -188,17 +195,17 @@ export default function relationalStoreQueryTest(){ }catch(err){ console.info(TAG + "RdbRemoteQueryPromiseTest0020 error:" + err) } - + done(); console.info(TAG + "RdbRemoteQueryPromiseTest0020 end") }) /** - * @tc.name RelationalStore remotequery test - * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0030 - * @tc.desc RelationalStore remotequery function test - */ - it('RdbRemoteQueryPromiseTest0030', 0, async function (done){ + * @tc.name RelationalStore remotequery test + * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0030 + * @tc.desc RelationalStore remotequery function test + */ + it('RdbRemoteQueryPromiseTest0030', 0, async function (done){ console.info(TAG + "RdbRemoteQueryPromiseTest0030 start") let predicates = new data_Rdb.RdbPredicates("test"); predicates.equalTo("name", "zhangsan") @@ -212,17 +219,17 @@ export default function relationalStoreQueryTest(){ }catch(err){ console.info(TAG + "RdbRemoteQueryPromiseTest0030 error:" + err) } - + done(); console.info(TAG + "RdbRemoteQueryPromiseTest0030 end") }) /** - * @tc.name RelationalStore remotequery test - * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0040 - * @tc.desc RelationalStore remotequery function test - */ - it('RdbRemoteQueryPromiseTest0040', 0, async function (done){ + * @tc.name RelationalStore remotequery test + * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Promise_0040 + * @tc.desc RelationalStore remotequery function test + */ + it('RdbRemoteQueryPromiseTest0040', 0, async function (done){ console.info(TAG + "RdbRemoteQueryPromiseTest0040 start") let predicates = new data_Rdb.RdbPredicates("test"); predicates.equalTo("name", "zhangsan") @@ -236,17 +243,17 @@ export default function relationalStoreQueryTest(){ }catch(err){ console.info(TAG + "RdbRemoteQueryPromiseTest0040 error:" + err) } - + done(); console.info(TAG + "RdbRemoteQueryPromiseTest0040 end") }) /** - * @tc.name RelationalStore remotequery test - * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0010 - * @tc.desc RelationalStore remotequery function test - */ - it('RdbRemoteQueryCallbackTest0010', 0, async function (done){ + * @tc.name RelationalStore remotequery test + * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0010 + * @tc.desc RelationalStore remotequery function test + */ + it('RdbRemoteQueryCallbackTest0010', 0, async function (done){ console.info(TAG + "RdbRemoteQueryCallbackTest0010 start") let predicates = new data_Rdb.RdbPredicates("test"); predicates.equalTo("name", "zhangsan") @@ -256,23 +263,23 @@ export default function relationalStoreQueryTest(){ console.info(TAG + "Remote query error" + err) }else{ console.info(TAG + "Remote query success") - expect(false).assertTrue(); + expect(false).assertTrue(); } }) }catch(err){ console.info(TAG + "RdbRemoteQueryCallbackTest0010 error:" + err) } - + done(); console.info(TAG + "RdbRemoteQueryCallbackTest0010 end") }) /** - * @tc.name RelationalStore remotequery test - * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0020 - * @tc.desc RelationalStore remotequery function test - */ - it('RdbRemoteQueryCallbackTest0020', 0, async function (done){ + * @tc.name RelationalStore remotequery test + * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0020 + * @tc.desc RelationalStore remotequery function test + */ + it('RdbRemoteQueryCallbackTest0020', 0, async function (done){ console.info(TAG + "RdbRemoteQueryCallbackTest0020 start") let predicates = new data_Rdb.RdbPredicates("test"); predicates.equalTo("name", "zhangsan") @@ -282,23 +289,23 @@ export default function relationalStoreQueryTest(){ console.info(TAG + "Remote query error" + err) }else{ console.info(TAG + "Remote query success") - expect(false).assertTrue(); + expect(false).assertTrue(); } }) }catch(err){ console.info(TAG + "RdbRemoteQueryCallbackTest0020 error:" + err) } - + done(); console.info(TAG + "RdbRemoteQueryCallbackTest0020 end") }) /** - * @tc.name RelationalStore remotequery test - * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0030 - * @tc.desc RelationalStore remotequery function test - */ - it('RdbRemoteQueryCallbackTest0030', 0, async function (done){ + * @tc.name RelationalStore remotequery test + * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0030 + * @tc.desc RelationalStore remotequery function test + */ + it('RdbRemoteQueryCallbackTest0030', 0, async function (done){ console.info(TAG + "RdbRemoteQueryCallbackTest0020 start") let predicates = new data_Rdb.RdbPredicates("test"); predicates.equalTo("name", "zhangsan") @@ -308,23 +315,23 @@ export default function relationalStoreQueryTest(){ console.info(TAG + "Remote query error" + err) }else{ console.info(TAG + "Remote query success") - expect(false).assertTrue(); + expect(false).assertTrue(); } }) }catch(err){ console.info(TAG + "RdbRemoteQueryCallbackTest0030 error:" + err) } - + done(); console.info(TAG + "RdbRemoteQueryCallbackTest0030 end") }) /** - * @tc.name RelationalStore remotequery test - * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0040 - * @tc.desc RelationalStore remotequery function test - */ - it('RdbRemoteQueryCallbackTest0040', 0, async function (done){ + * @tc.name RelationalStore remotequery test + * @tc.number SUB_DDM_RelationalStore_JS_RemoteQueryTest_Callback_0040 + * @tc.desc RelationalStore remotequery function test + */ + it('RdbRemoteQueryCallbackTest0040', 0, async function (done){ console.info(TAG + "RdbRemoteQueryCallbackTest0040 start") let predicates = new data_Rdb.RdbPredicates("test"); predicates.equalTo("name", "zhangsan") @@ -334,13 +341,13 @@ export default function relationalStoreQueryTest(){ console.info(TAG + "Remote query error" + err) }else{ console.info(TAG + "Remote query success") - expect(false).assertTrue(); + expect(false).assertTrue(); } }) }catch(err){ console.info(TAG + "RdbRemoteQueryCallbackTest0040 error:" + err) } - + done(); console.info(TAG + "RdbRemoteQueryCallbackTest0040 end") }) -- GitLab