From 066f17884a24740056ba6c5daf39108ff053803a Mon Sep 17 00:00:00 2001 From: liangzhenyu123 Date: Wed, 3 Aug 2022 11:28:00 +0800 Subject: [PATCH] liangzhenyu6@huawei.com Signed-off-by: liangzhenyu123 --- .../hap/src/main/js/test/List.test.js | 2 +- .../js/test/RdbstoreRdbstoreJsunit.test.js | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/test/List.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/test/List.test.js index 5a6a7ed7d..35782cc0d 100644 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/test/List.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/test/List.test.js @@ -30,7 +30,7 @@ import storageCallBackTest from './StorageCallBackJsunit.test.js' import storageHelperTest from './StorageHelperJsunit.test.js' import storagePromiseTest from './StoragePromiseJsunit.test.js' import storageSyncTest from './StorageSyncJsunit.test.js' -import systemStorageTest from './SystemStorageJsunit.testjs' +import systemStorageTest from './SystemStorageJsunit.test.js' export default function testsuite() { dataAbilityPredicatesTest() rdbStoreBackupRestoreWithFAContextTest() diff --git a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/test/RdbstoreRdbstoreJsunit.test.js b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/test/RdbstoreRdbstoreJsunit.test.js index 971e5ef61..6d7e9c81d 100644 --- a/distributeddatamgr/appdatamgrjstest/hap/src/main/js/test/RdbstoreRdbstoreJsunit.test.js +++ b/distributeddatamgr/appdatamgrjstest/hap/src/main/js/test/RdbstoreRdbstoreJsunit.test.js @@ -15,6 +15,9 @@ import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from '@ohos/hypium' import dataRdb from '@ohos.data.rdb'; +import abilityFeatureAbility from '@ohos.ability.featureAbility'; + +var context = abilityFeatureAbility.getContext(); const TAG = "[RDB_JSKITS_TEST]" const CREATE_TABLE_TEST = "CREATE TABLE IF NOT EXISTS test (" + "id INTEGER PRIMARY KEY AUTOINCREMENT, " + "name TEXT NOT NULL, " + "age INTEGER, " + "salary REAL, " + "blobType BLOB)"; @@ -170,6 +173,60 @@ describe('rdbStoreTest', function () { done(); console.info(TAG + "************* testRdbStore0005 end *************"); }) + + /** + * @tc.name rdb store getRdbStore test + * @tc.number SUB_DDM_AppDataFWK_JSRDB_RdbStore_0060 + * @tc.desc rdb store getRdbStore test + */ + it('testRdbStore0006', 0, async function (done) { + console.info(TAG + "************* testRdbStore0006 start *************"); + let rdbstore = null; + try{ + const STORE_CONFIG = { + name: "rdbstorecontext.db", + } + console.info(TAG + "first") + await dataRdb.getRdbStore(context,STORE_CONFIG, 1).then((data) => { + console.info(TAG + "Get rdbstore success") + rdbstore = data; + expect(rdbstore != null).assertTrue(); + }).catch((errInfo) => { + console.info(TAG + "Get rdbstore fail " + errInfo) + expect(null).assertFail(); + }) + }catch(err){ + console.info(TAG + "Get rdbstore fail catch err: " + err) + expect(null).assertFail() + } + await dataRdb.deleteRdbStore(STORE_CONFIG.name) + rdbstore = null; + done(); + console.info(TAG + "************* testRdbStore0006 end *************"); + }) + + /** + * @tc.name rdb store getRdbStore test + * @tc.number SUB_DDM_AppDataFWK_JSRDB_RdbStore_0070 + * @tc.desc rdb store getRdbStore test + */ + it('testRdbStore0007', 0, async function (done) { + console.info(TAG + "************* testRdbStore0007 start *************"); + let rdbstore = null; + dataRdb.getRdbStore(context,STORE_CONFIG, 1, (data,err) => { + if(err != undefined){ + expect(null).assertFail() + }else{ + rdbstore = data; + console.info(TAG + "getRdbStore success: " + rdbstore) + expect(rdbstore).assertNotNull(); + } + }); + await dataRdb.deleteRdbStore(STORE_CONFIG.name) + rdbstore = null; + done(); + console.info(TAG + "************* testRdbStore0007 end *************"); + }) console.info(TAG + "*************Unit Test End*************"); })} -- GitLab