Skip to content
代码片段 群组 项目
提交 9ebf2686 编辑于 作者: Timotej Ecimovic's avatar 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
无相关合并请求
/**
*
* 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()
)
......@@ -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.
先完成此消息的编辑!
想要评论请 注册