Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
93dd4e67
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
1 年多 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
93dd4e67
编写于
2月 24, 2022
作者:
W
wellinleo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update schema and fieldNode testcase
Signed-off-by:
N
wellinleo
<
yangliu146@huawei.com
>
上级
6405727b
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
235 addition
and
16 deletion
+235
-16
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/FieldNodeJsunit.test.js
...test/hap/src/main/js/default/test/FieldNodeJsunit.test.js
+136
-6
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SchemaJsunit.test.js
...rjstest/hap/src/main/js/default/test/SchemaJsunit.test.js
+99
-10
未找到文件。
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/FieldNodeJsunit.test.js
浏览文件 @
93dd4e67
...
...
@@ -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
distributeddatamgr/distributeddatamgrjstest/hap/src/main/js/default/test/SchemaJsunit.test.js
浏览文件 @
93dd4e67
...
...
@@ -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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录