yao/widgets/widgets_test.go
2022-09-26 21:50:04 +08:00

45 lines
739 B
Go

package widgets
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
"github.com/yaoapp/yao/config"
"github.com/yaoapp/yao/lang"
"github.com/yaoapp/yao/model"
"github.com/yaoapp/yao/script"
"github.com/yaoapp/yao/share"
)
func TestLoad(t *testing.T) {
prepare(t)
err := Load(config.Conf)
assert.Nil(t, err)
}
func prepare(t *testing.T, language ...string) {
// langs
if len(language) < 1 {
os.Unsetenv("YAO_LANG")
} else {
os.Setenv("YAO_LANG", language[0])
}
lang.Load(config.Conf)
share.DBConnect(config.Conf.DB) // removed later
// load scripts
err := script.Load(config.Conf)
if err != nil {
t.Fatal(err)
}
// load models
err = model.Load(config.Conf)
if err != nil {
t.Fatal(err)
}
}