diff --git a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SchemaJsunit.test.js b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SchemaJsunit.test.js index 2f3c2c50abd0977dd9b224f35ecb5546bee527fd..38110bf002ba0eeafb3f9d9b89c34907b2c5faa4 100644 --- a/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SchemaJsunit.test.js +++ b/distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SchemaJsunit.test.js @@ -15,6 +15,16 @@ import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'deccjsunit/index' import ddm from '@ohos.data.distributedData'; +const TEST_BUNDLE_NAME = 'ohos.acts.distributeddatamgr'; + +const config = { + bundleName : TEST_BUNDLE_NAME, + userInfo : { + userId : '0', + userType : ddm.UserType.SAME_USER_ID + } +} + describe('SchemaTest', function() { // toJsonString():string @@ -33,9 +43,24 @@ describe('SchemaTest', function() { try { let schema = new ddm.Schema(); var str = schema.toJsonString(); - schema.root = new ddm.FieldNode(); - var node = schema.root; - console.log("schema: " + str); + console.log("testToJsonString002: " + str); + const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : ddm.KVStoreType.SINGLE_VERSION, + schema : str, + securityLevel : ddm.SecurityLevel.S2, + } + console.log("testToJsonString002: createKVManager (single) with " + JSON.stringify(options)); + await ddm.createKVManager(config).then((manager) => { + var kvManager = manager; + console.log('testToJsonString002 createKVManager success'); + }).catch((err) => { + console.log('testToJsonString002 createKVManager err ' + err); + }); + } catch (e) { expect(null).assertFail(); } @@ -46,7 +71,25 @@ describe('SchemaTest', function() { try { let schema = new ddm.Schema(); var str = schema.toJsonString(); - console.log("schema: " + str); + console.log("testToJsonString003: " + str); + + const options = { + createIfMissing : true, + encrypt : false, + backup : false, + autoSync : true, + kvStoreType : ddm.KVStoreType.DEVICE_COLLABORATION, + schema : str, + securityLevel : ddm.SecurityLevel.S2, + } + console.log("testToJsonString003: createKVManager (device) with " + JSON.stringify(options)); + await ddm.createKVManager(config).then((manager) => { + var kvManager = manager; + console.log('testToJsonString003 createKVManager success'); + }).catch((err) => { + console.log('testToJsonString003 createKVManager err ' + err); + }); + } catch (e) { expect(null).assertFail(); }