提交 93dd4e67 编写于 作者: W wellinleo

update schema and fieldNode testcase

Signed-off-by: Nwellinleo <yangliu146@huawei.com>
上级 6405727b
......@@ -31,7 +31,6 @@ describe('FieldNodeTest', function() {
node.appendChild(child1);
node.appendChild(child2);
node.appendChild(child3);
console.log("appendNode " + node.toJson());
child1 = null;
child2 = null;
child3 = null;
......@@ -53,7 +52,6 @@ describe('FieldNodeTest', function() {
let node = new ddm.FieldNode("root");
let child = new ddm.FieldNode("child");
node.appendChild(child);
console.log("appendNode " + node.toJson());
child = null;
node = null;
} catch (e) {
......@@ -72,7 +70,6 @@ describe('FieldNodeTest', function() {
let node = new ddm.FieldNode("root");
let child = new ddm.FieldNode();
node.appendChild(child);
console.log("appendNode " + node.toJson());
expect(null).assertFail();
} catch (e) {
console.log("testAppendChild003 is ok :" + e);
......@@ -90,7 +87,6 @@ describe('FieldNodeTest', function() {
let node = new ddm.FieldNode("root");
let child = new ddm.FieldNode("child");
node.appendChild(child);
console.log("appendNode " + node.toJson());
} catch (e) {
expect(null).assertFail();
}
......@@ -107,7 +103,6 @@ describe('FieldNodeTest', function() {
let node = new ddm.FieldNode("root");
let child = new ddm.FieldNode("child");
node.appendChild(child);
console.log("appendNode " + node.toJson());
} catch (e) {
expect(null).assertFail();
}
......@@ -124,11 +119,146 @@ describe('FieldNodeTest', function() {
let node = new ddm.FieldNode();
let child = new ddm.FieldNode();
node.appendChild(child);
console.log("appendNode " + node.toJson());
expect(null).assertFail();
} catch (e) {
console.log("testToJson003 is ok : " + e);
}
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_FIELDNODE_DEFAULT_0100
* @tc.name [JS-API8]FieldNode.default.
* @tc.desc Test Js Api FieldNode.default testcase 001
*/
it('testdefault001', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.default = 'first name';
console.info('defaultValue = ' + node.default);
expect(node.default === 'first name').assertTrue()
} catch (e) {
console.log("testdefault001 fail on exception: " + e);
}
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_FIELDNODE_NULLABLE_0100
* @tc.name [JS-API8]FieldNode.nullable.
* @tc.desc Test Js Api FieldNode.nullable testcase 001
*/
it('testnullable001', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.nullable = false;
console.info('nullable = ' + node.nullable);
expect(node.nullable === false).assertTrue()
} catch (e) {
console.log("testnullable001 fail on exception: " + e);
}
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_FIELDNODE_TYPE_STRING_0100
* @tc.name [JS-API8]FieldNode.type.STRING
* @tc.desc Test Js Api FieldNode.type testcase 001
*/
it('testtype001', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.type = ddm.type.STRING;
console.info('type = ' + node.type);
expect(node.type === ddm.type.STRING).assertTrue()
} catch (e) {
console.log("testtype001 fail on exception: " + e);
}
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_FIELDNODE_TYPE_INTEGER_0200
* @tc.name [JS-API8]FieldNode.type.INTEGER
* @tc.desc Test Js Api FieldNode.type testcase 002
*/
it('testtype002', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.type = ddm.type.INTEGER;
console.info('type = ' + node.type);
expect(node.type === ddm.type.INTEGER).assertTrue()
} catch (e) {
console.log("testtype002 fail on exception: " + e);
}
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_FIELDNODE_TYPE_FLOAT_0300
* @tc.name [JS-API8]FieldNode.type.FLOAT
* @tc.desc Test Js Api FieldNode.type testcase 003
*/
it('testtype003', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.type = ddm.type.FLOAT;
console.info('type = ' + node.type);
expect(node.type === ddm.type.FLOAT).assertTrue()
} catch (e) {
console.log("testtype003 fail on exception: " + e);
}
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_FIELDNODE_TYPE_BYTE_ARRAY_0400
* @tc.name [JS-API8]FieldNode.type.BYTE_ARRAY
* @tc.desc Test Js Api FieldNode.type testcase 004
*/
it('testtype004', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.type = ddm.type.BYTE_ARRAY;
console.info('type = ' + node.type);
expect(node.type === ddm.type.BYTE_ARRAY).assertTrue()
} catch (e) {
console.log("testtype004 fail on exception: " + e);
}
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_FIELDNODE_TYPE_BOOLEAN_0500
* @tc.name [JS-API8]FieldNode.type.BOOLEAN
* @tc.desc Test Js Api FieldNode.type testcase 005
*/
it('testtype005', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.type = ddm.type.BOOLEAN;
console.info('type = ' + node.type);
expect(node.type === ddm.ValueType.BOOLEAN).assertTrue()
} catch (e) {
console.log("testtype005 fail on exception: " + e);
}
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_FIELDNODE_TYPE_DOUBLE_0100
* @tc.name [JS-API8]FieldNode.type.DOUBLE
* @tc.desc Test Js Api FieldNode.type testcase 006
*/
it('testtype006', 0, async function(done) {
try {
let node = new ddm.FieldNode('first');
node.type = ddm.type.DOUBLE;
console.info('type = ' + node.type);
expect(node.type === ddm.type.DOUBLE).assertTrue()
} catch (e) {
console.log("testtype006 fail on exception: " + e);
}
done();
})
})
\ No newline at end of file
......@@ -15,7 +15,7 @@
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 TEST_BUNDLE_NAME = 'ohos.example.mutest.service';
const TEST_STORE_ID = 'storeId';
var kvManager = null;
......@@ -98,7 +98,7 @@ describe('SchemaTest', function() {
backup : false,
autoSync : true,
kvStoreType : ddm.KVStoreType.SINGLE_VERSION,
schema : '',
schema : {},
securityLevel : ddm.SecurityLevel.NO_LEVEL,
}
......@@ -171,7 +171,6 @@ describe('SchemaTest', function() {
let schema = new ddm.Schema();
schema.root.appendChild(english);
schema.indexes = ['$.english.first', '$.english.second'];
console.log("schema: " + schema.toJsonString());
} catch (e) {
console.log("schema fail on exception: " + e);
expect(null).assertFail();
......@@ -204,10 +203,8 @@ describe('SchemaTest', function() {
let schema = new ddm.Schema();
schema.root.appendChild(english);
schema.indexes = ['$.english.first', '$.english.second'];
console.log("schema: " + schema.toJsonString());
options.kvStoreType = ddm.KVStoreType.DEVICE_COLLABORATION;
options.schema = schema.toJsonString();
options.schema = schema;
await testPutAndGet(kvManager, options);
console.log("schematestPutAndGet done");
} catch (e) {
......@@ -233,9 +230,8 @@ describe('SchemaTest', function() {
schema.root.appendChild(name);
schema.indexes = ['$.name'];
schema.mode = 1; // STRICT
console.log("schema: " + schema.toJsonString());
options.kvStoreType = ddm.KVStoreType.SINGLE_VERSION;
options.schema = schema.toJsonString();
options.schema = schema;
await kvManager.getKVStore(TEST_STORE_ID, options).then(async (store) => {
console.log('testToJsonString003 getKVStore success' + JSON.stringify(options));
kvStore = store;
......@@ -275,7 +271,6 @@ describe('SchemaTest', function() {
let schema = new ddm.Schema();
schema.root.appendChild(english);
console.log("schema without indexes: " + schema.toJsonString());
schema.indexes = []; // indexex set to empty array -> invalid indexes.
expect(null).assertFail();
} catch (e) {
......@@ -283,4 +278,98 @@ describe('SchemaTest', function() {
}
done();
})
})
\ No newline at end of file
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_SCHEMA_ROOT_0100
* @tc.name [JS-API8]Schema.root
* @tc.desc Test Js Api Schema.root testcase 001
*/
it('testroot001', 0, async function(done) {
try {
let english = new ddm.FieldNode('english');
english.type = ddm.ValueType.STRING;
let schema = new ddm.Schema();
expect(schema.root instanceof ddm.FieldNode).assertTrue();
} catch (e) {
console.log("schema fail on exception: " + e);
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_SCHEMA_INDEXES_0100
* @tc.name [JS-API8]Schema.indexes
* @tc.desc Test Js Api Schema.indexes testcase 001
*/
it('testindexes001', 0, async function(done) {
try {
let schema = new ddm.Schema();
schema.indexes = ['$.english.first', '$.english.second'];
expect(schema.indexes[0] === '$.english.first' && schema.indexes[1] === '$.english.second').assertTrue();
} catch (e) {
console.log("schema fail on exception: " + e);
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_SCHEMA_MODE_0100
* @tc.name [JS-API8]Schema.mode
* @tc.desc Test Js Api Schema.mode testcase 001
*/
it('testmode001', 0, async function(done) {
try {
let schema = new ddm.Schema();
schema.mode = 1;
console.log("schema mode = "+schema.mode)
expect(schema.mode === 1).assertTrue();
} catch (e) {
console.log("schema fail on exception: " + e);
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_SCHEMA_MODE_0200
* @tc.name [JS-API8]Schema.mode
* @tc.desc Test Js Api Schema.mode testcase 002
*/
it('testmode002', 0, async function(done) {
try {
let schema = new ddm.Schema();
schema.mode = 0;
console.log("schema mode = "+schema.mode)
expect(schema.mode === 0).assertTrue();
} catch (e) {
console.log("schema fail on exception: " + e);
expect(null).assertFail();
}
done();
})
/**
* @tc.number SUB_DISTRIBUTEDDATAMGR_SCHEMA_SKIP_0100
* @tc.name [JS-API8]Schema.skip
* @tc.desc Test Js Api Schema.skip testcase 001
*/
it('testskip001', 0, async function(done) {
try {
let schema = new ddm.Schema();
schema.skip = 0;
expect(schema.skip === 0).assertTrue();
} catch (e) {
console.log("schema fail on exception: " + e);
expect(null).assertFail();
}
done();
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册