Skip to content
GitLab
菜单
为什么选择 GitLab
定价
联系销售
探索
为什么选择 GitLab
定价
联系销售
探索
登录
获取免费试用
主导航
搜索或转到…
项目
Z
zap
管理
动态
成员
标记
计划
议题
议题看板
里程碑
迭代
Wiki
代码
合并请求
仓库
分支
提交
标签
仓库图
比较修订版本
代码片段
锁定的文件
构建
流水线
作业
流水线计划
产物
部署
发布
Package registry
容器镜像库
模型注册表
运维
环境
Terraform 模块
监控
事件
服务台
分析
价值流分析
贡献者分析
CI/CD 分析
仓库分析
代码评审分析
议题分析
模型实验
效能分析
帮助
帮助
支持
GitLab 文档
比较 GitLab 各版本
社区论坛
为极狐GitLab 提交贡献
提交反馈
隐私声明
快捷键
?
新增功能
4
代码片段
群组
项目
显示更多面包屑
esp-mirror
project-chip
zap
提交
9ebf2686
提交
9ebf2686
编辑于
3 years ago
作者:
Timotej Ecimovic
浏览文件
操作
下载
补丁
差异文件
Add a unit test that is not burdened by the XML or gen template counts.
上级
be339640
No related branches found
分支 包含提交
No related tags found
标签 包含提交
无相关合并请求
变更
2
隐藏空白变更内容
行内
左右并排
显示
2 个更改的文件
test/gen-meta.test.js
+103
-0
103 个添加, 0 个删除
test/gen-meta.test.js
test/test-util.js
+5
-0
5 个添加, 0 个删除
test/test-util.js
有
108 个添加
和
0 个删除
test/gen-meta.test.js
0 → 100644
+
103
−
0
浏览文件 @
9ebf2686
/**
*
* Copyright (c) 2020 Silicon Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* @jest-environment node
*/
const
path
=
require
(
'
path
'
)
const
genEngine
=
require
(
'
../src-electron/generator/generation-engine.js
'
)
const
env
=
require
(
'
../src-electron/util/env.js
'
)
const
dbApi
=
require
(
'
../src-electron/db/db-api.js
'
)
const
zclLoader
=
require
(
'
../src-electron/zcl/zcl-loader.js
'
)
const
importJs
=
require
(
'
../src-electron/importexport/import.js
'
)
const
testUtil
=
require
(
'
./test-util.js
'
)
const
queryPackage
=
require
(
'
../src-electron/db/query-package.js
'
)
let
db
const
testFile
=
path
.
join
(
__dirname
,
'
resource/three-endpoint-device.zap
'
)
let
sessionId
let
templateContext
let
zclContext
beforeAll
(
async
()
=>
{
let
file
=
env
.
sqliteTestFile
(
'
testmeta
'
)
db
=
await
dbApi
.
initDatabaseAndLoadSchema
(
file
,
env
.
schemaFile
(),
env
.
zapVersion
()
)
},
testUtil
.
timeout
.
medium
())
afterAll
(()
=>
dbApi
.
closeDatabase
(
db
),
testUtil
.
timeout
.
short
())
test
(
'
Meta test - template loading
'
,
async
()
=>
{
templateContext
=
await
genEngine
.
loadTemplates
(
db
,
testUtil
.
testTemplate
.
meta
)
expect
(
templateContext
.
crc
).
not
.
toBeNull
()
expect
(
templateContext
.
templateData
).
not
.
toBeNull
()
expect
(
templateContext
.
templateData
.
name
).
toEqual
(
'
Meta test templates
'
)
expect
(
templateContext
.
templateData
.
version
).
toEqual
(
'
meta-test
'
)
expect
(
templateContext
.
packageId
).
not
.
toBeNull
()
},
testUtil
.
timeout
.
medium
()
)
test
(
'
Meta test - zcl loading
'
,
async
()
=>
{
zclContext
=
await
zclLoader
.
loadZcl
(
db
,
testUtil
.
testZclMetafile
)
},
testUtil
.
timeout
.
medium
()
)
test
(
'
Meta test - file import
'
,
async
()
=>
{
let
importResult
=
await
importJs
.
importDataFromFile
(
db
,
testFile
)
sessionId
=
importResult
.
sessionId
expect
(
sessionId
).
not
.
toBeNull
()
await
queryPackage
.
insertSessionPackage
(
db
,
sessionId
,
zclContext
.
packageId
)
},
testUtil
.
timeout
.
medium
()
)
test
(
'
Meta test - generation
'
,
async
()
=>
{
let
genResult
=
await
genEngine
.
generate
(
db
,
sessionId
,
templateContext
.
packageId
,
{},
{
disableDeprecationWarnings
:
true
,
}
)
expect
(
genResult
).
not
.
toBeNull
()
expect
(
genResult
.
partial
).
toBeFalsy
()
expect
(
genResult
.
content
).
not
.
toBeNull
()
let
epc
=
genResult
.
content
[
'
test1.out
'
]
expect
(
epc
).
not
.
toBeNull
()
},
testUtil
.
timeout
.
medium
()
)
此差异已折叠。
点击以展开。
test/test-util.js
+
5
−
0
浏览文件 @
9ebf2686
...
...
@@ -15,6 +15,8 @@
* limitations under the License.
*/
const
path
=
require
(
'
path
'
)
function
testServer
(
fileName
)
{
let
testPort
if
(
fileName
.
includes
(
'
server-bare.test
'
))
{
...
...
@@ -83,8 +85,11 @@ exports.testTemplate = {
dotdotCount
:
5
,
unittest
:
'
./test/gen-template/test/gen-test.json
'
,
testCount
:
3
,
meta
:
'
./test/resource/meta/gen-test.json
'
,
}
exports
.
testZclMetafile
=
path
.
join
(
__dirname
,
'
./resource/meta/zcl.json
'
)
exports
.
testServer
=
testServer
exports
.
testCustomXml
=
'
./test/resource/test-custom.xml
'
...
...
此差异已折叠。
点击以展开。
预览
0%
加载中
请重试
或
添加新附件
.
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
保存评论
取消
想要评论请
注册
或
登录