Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
919aa67e
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看板
未验证
提交
919aa67e
编写于
6月 29, 2023
作者:
O
openharmony_ci
提交者:
Gitee
6月 29, 2023
浏览文件
操作
浏览文件
下载
差异文件
!9130 【Distributeddatamgr】【Master】RelationalStore用例新增
Merge pull request !9130 from yanglifeng/master
上级
06833552
0fed94a5
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
242 addition
and
0 deletion
+242
-0
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreDistributedJsunit.test.js
...src/main/js/test/RelationalStoreDistributedJsunit.test.js
+242
-0
未找到文件。
distributeddatamgr/relationalStoretest/relationalStoreJstest/hap/src/main/js/test/RelationalStoreDistributedJsunit.test.js
浏览文件 @
919aa67e
...
...
@@ -420,6 +420,248 @@ describe('relationalStoreDistributedTest', function () {
done
();
})
/**
* @tc.name sync test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_016
* @tc.desc sync test
*/
it
(
'
SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_016
'
,
0
,
function
(
done
)
{
let
predicates
=
new
data_Rdb
.
RdbPredicates
(
"
employee
"
)
predicates
=
predicates
.
inDevices
(
"
12345678abcd
"
);
console
.
info
(
TAG
+
`SYNC_MODE_TIME_FIRST = `
+
data_Rdb
.
SyncMode
.
SYNC_MODE_TIME_FIRST
);
expect
(
data_Rdb
.
SyncMode
.
SYNC_MODE_TIME_FIRST
).
assertEqual
(
4
);
console
.
info
(
TAG
+
"
DATA_CHANGE =
"
+
data_Rdb
.
ChangeType
.
DATA_CHANGE
);
expect
(
data_Rdb
.
ChangeType
.
DATA_CHANGE
).
assertEqual
(
0
);
console
.
info
(
TAG
+
"
ASSET_CHANGE =
"
+
data_Rdb
.
ChangeType
.
ASSET_CHANGE
);
expect
(
data_Rdb
.
ChangeType
.
ASSET_CHANGE
).
assertEqual
(
1
);
try
{
rdbStore
.
sync
(
data_Rdb
.
SyncMode
.
SYNC_MODE_TIME_FIRST
,
predicates
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
TAG
+
`Sync failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
expect
(
err
===
null
).
assertFail
();
}
console
.
info
(
TAG
+
`Sync done.`
+
result
);
expect
(
result
!==
null
).
assertFail
();
})
}
catch
(
error
){
console
.
error
(
TAG
+
`failed, code is
${
error
.
code
}
,message is
${
error
.
message
}
`
);
expect
(
error
.
code
).
assertEqual
(
'
401
'
);
done
();
}
})
/**
* @tc.name sync test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_016
* @tc.desc sync test
*/
it
(
'
SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_017
'
,
0
,
function
(
done
)
{
let
predicates
=
new
data_Rdb
.
RdbPredicates
(
"
employee
"
)
predicates
=
predicates
.
inDevices
(
"
12345678abcd
"
);
console
.
info
(
TAG
+
`SYNC_MODE_NATIVE_FIRST = `
+
data_Rdb
.
SyncMode
.
SYNC_MODE_NATIVE_FIRST
);
expect
(
data_Rdb
.
SyncMode
.
SYNC_MODE_NATIVE_FIRST
).
assertEqual
(
5
);
try
{
rdbStore
.
sync
(
data_Rdb
.
SyncMode
.
SYNC_MODE_NATIVE_FIRST
,
predicates
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
TAG
+
`Sync failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
expect
(
err
===
null
).
assertFail
();
}
console
.
info
(
TAG
+
`Sync done.`
+
result
);
expect
(
result
!==
null
).
assertFail
();
})
}
catch
(
error
){
console
.
error
(
TAG
+
`failed, code is
${
error
.
code
}
,message is
${
error
.
message
}
`
);
expect
(
error
.
code
).
assertEqual
(
'
401
'
);
done
();
}
})
/**
* @tc.name sync test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_018
* @tc.desc sync test
*/
it
(
'
SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_018
'
,
0
,
function
(
done
)
{
let
predicates
=
new
data_Rdb
.
RdbPredicates
(
"
employee
"
)
predicates
=
predicates
.
inDevices
(
"
12345678abcd
"
);
console
.
info
(
TAG
+
`SYNC_MODE_CLOUD_FIRST = `
+
data_Rdb
.
SyncMode
.
SYNC_MODE_CLOUD_FIRST
);
expect
(
data_Rdb
.
SyncMode
.
SYNC_MODE_CLOUD_FIRST
).
assertEqual
(
6
);
try
{
rdbStore
.
sync
(
data_Rdb
.
SyncMode
.
SYNC_MODE_CLOUD_FIRST
,
predicates
,
function
(
err
,
result
)
{
if
(
err
)
{
console
.
error
(
TAG
+
`Sync failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
expect
(
err
===
null
).
assertFail
();
}
console
.
info
(
TAG
+
`Sync done.`
+
result
);
expect
(
result
!==
null
).
assertFail
();
})
}
catch
(
error
){
console
.
error
(
TAG
+
`failed, code is
${
error
.
code
}
,message is
${
error
.
message
}
`
);
expect
(
error
.
code
).
assertEqual
(
'
401
'
);
done
();
}
})
/**
* @tc.name sync test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_019
* @tc.desc sync test
*/
it
(
'
SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_019
'
,
0
,
function
(
done
)
{
try
{
rdbStore
.
on
(
"
dataChange
"
,
data_Rdb
.
SubscribeType
.
SUBSCRIBE_TYPE_CLOUD
,
function
(
devices
)
{
console
.
info
(
TAG
+
devices
+
"
dataChange
"
);
expect
(
devices
).
assertEqual
(
null
);
});
}
catch
(
err
){
console
.
info
(
TAG
+
"
on dataChange
"
+
err
);
expect
(
err
!==
null
).
assertFalse
();
}
done
();
})
/**
* @tc.name sync test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_020
* @tc.desc sync test
*/
it
(
'
SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_020
'
,
0
,
function
(
done
)
{
try
{
rdbStore
.
on
(
'
dataChange
'
,
data_Rdb
.
SubscribeType
.
SUBSCRIBE_TYPE_CLOUD_DETAILS
,
function
(
table
)
{
console
.
info
(
TAG
+
table
+
"
dataChange
"
);
expect
(
table
).
assertEqual
(
null
);
});
}
catch
(
err
){
console
.
info
(
TAG
+
"
on dataChange
"
+
err
);
expect
(
err
!==
null
).
assertFalse
();
}
done
();
})
/**
* @tc.name sync test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_021
* @tc.desc sync test
*/
it
(
'
SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_021
'
,
0
,
function
(
done
)
{
try
{
rdbStore
.
on
(
'
dataChange
'
,
data_Rdb
.
SubscribeType
.
SUBSCRIBE_TYPE_CLOUD_DETAILS
,
function
(
type
)
{
console
.
info
(
TAG
+
type
+
"
dataChange
"
);
expect
(
type
).
assertEqual
(
null
);
});
}
catch
(
err
){
console
.
info
(
TAG
+
"
on dataChange
"
+
err
);
expect
(
err
!==
null
).
assertFalse
();
}
done
();
})
/**
* @tc.name sync test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_022
* @tc.desc sync test
*/
it
(
'
SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_022
'
,
0
,
function
(
done
)
{
function
Observer
(
inserted
)
{
console
.
info
(
TAG
+
inserted
+
"
dataChange
"
);
expect
(
inserted
).
assertEqual
(
null
);
}
try
{
rdbStore
.
on
(
'
dataChange
'
,
data_Rdb
.
SubscribeType
.
SUBSCRIBE_TYPE_CLOUD_DETAILS
,
Observer
);
}
catch
(
err
){
console
.
info
(
TAG
+
"
on dataChange
"
+
err
);
expect
(
err
!==
null
).
assertFalse
();
}
done
();
})
/**
* @tc.name sync test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_023
* @tc.desc sync test
*/
it
(
'
SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_023
'
,
0
,
function
(
done
)
{
try
{
rdbStore
.
on
(
'
dataChange
'
,
data_Rdb
.
SubscribeType
.
SUBSCRIBE_TYPE_CLOUD_DETAILS
,
function
(
updated
)
{
console
.
info
(
TAG
+
updated
+
"
dataChange
"
);
expect
(
updated
).
assertEqual
(
null
);
});
}
catch
(
err
){
console
.
info
(
TAG
+
"
on dataChange
"
+
err
);
expect
(
err
!==
null
).
assertFalse
();
}
done
();
})
/**
* @tc.name sync test
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_024
* @tc.desc sync test
*/
it
(
'
SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_024
'
,
0
,
function
(
done
)
{
try
{
rdbStore
.
on
(
'
dataChange
'
,
data_Rdb
.
SubscribeType
.
SUBSCRIBE_TYPE_CLOUD_DETAILS
,
function
(
deleted
)
{
console
.
info
(
TAG
+
deleted
+
"
dataChange
"
);
expect
(
deleted
).
assertEqual
(
null
);
});
}
catch
(
err
){
console
.
info
(
TAG
+
"
on dataChange
"
+
err
);
expect
(
err
!==
null
).
assertFalse
();
}
done
();
})
/**
* @tc.name set distributed table using two table name
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_025
* @tc.desc set distributed table type DISTRIBUTED_DEVICE
*/
it
(
'
SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_025
'
,
0
,
async
function
(
done
)
{
try
{
await
rdbStore
.
setDistributedTables
([
'
employee
'
],
data_Rdb
.
DistributedType
.
DISTRIBUTED_DEVICE
,
function
(
err
){
if
(
err
)
{
console
.
error
(
TAG
+
`SetDistributedTables failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
expect
(
null
).
assertFail
();
done
();
}
console
.
info
(
TAG
+
`SetDistributedTables successfully.`
);
expect
(
err
==
undefined
).
assertTrue
();
done
();
})
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
set employee to be distributed table failed
"
);
expect
(
null
).
assertFail
();
done
()
}
})
/**
* @tc.name set distributed table using two table name
* @tc.number SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_026
* @tc.desc set distributed table type DISTRIBUTED_CLOUD
*/
it
(
'
SUB_DDM_AppDataFWK_JSRelationalStore_Distributed_026
'
,
0
,
async
function
(
done
)
{
try
{
await
rdbStore
.
setDistributedTables
([
'
employee
'
],
data_Rdb
.
DistributedType
.
DISTRIBUTED_CLOUD
,
function
(
err
){
if
(
err
)
{
console
.
error
(
TAG
+
`SetDistributedTables failed, code is
${
err
.
code
}
,message is
${
err
.
message
}
`
);
expect
(
null
).
assertFail
();
done
();
}
console
.
info
(
TAG
+
`SetDistributedTables successfully.`
);
expect
(
err
==
undefined
).
assertTrue
();
done
();
})
}
catch
(
err
)
{
console
.
info
(
TAG
+
"
set employee and product to be distributed table failed
"
);
expect
(
null
).
assertFail
();
done
()
}
})
console
.
info
(
TAG
+
"
*************Unit Test End*************
"
);
})
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录