fix load test bug

This commit is contained in:
Max 2021-10-07 18:31:46 +08:00
parent 6ae845c91c
commit 7ce9552d17

View file

@ -5,18 +5,21 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/yaoapp/xiang/config"
"github.com/yaoapp/xiang/table"
)
func TestLoad(t *testing.T) {
defer Load(config.Conf)
assert.NotPanics(t, func() {
Load(Conf)
Load(config.Conf)
})
}
// 从文件系统载入引擎文件
func TestLoadEngineFS(t *testing.T) {
root := "fs://" + path.Join(Conf.Source, "/xiang")
defer Load(config.Conf)
root := "fs://" + path.Join(config.Conf.Source, "/xiang")
assert.NotPanics(t, func() {
LoadEngine(root)
})
@ -25,6 +28,7 @@ func TestLoadEngineFS(t *testing.T) {
// 从BinDataz载入引擎文件
func TestLoadEngineBin(t *testing.T) {
defer Load(config.Conf)
root := "bin://xiang"
assert.NotPanics(t, func() {
LoadEngine(root)
@ -33,21 +37,22 @@ func TestLoadEngineBin(t *testing.T) {
// 从文件系统载入应用脚本
func TestLoadAppFS(t *testing.T) {
defer Load(config.Conf)
assert.NotPanics(t, func() {
LoadApp(AppRoot{
APIs: Conf.RootAPI,
Flows: Conf.RootFLow,
Models: Conf.RootModel,
Plugins: Conf.RootPlugin,
Tables: Conf.RootTable,
Charts: Conf.RootChart,
Screens: Conf.RootScreen,
APIs: config.Conf.RootAPI,
Flows: config.Conf.RootFLow,
Models: config.Conf.RootModel,
Plugins: config.Conf.RootPlugin,
Tables: config.Conf.RootTable,
Charts: config.Conf.RootChart,
Screens: config.Conf.RootScreen,
})
})
}
func TestTableLoad(t *testing.T) {
defer Load(config.Conf)
table, has := table.Tables["service"]
assert.Equal(t, table.Table, "service")
assert.True(t, has)