yao/widgets/environment/environment_test.go
2022-10-03 19:08:02 +08:00

35 lines
882 B
Go

package environment
import (
"path/filepath"
"testing"
jsoniter "github.com/json-iterator/go"
"github.com/stretchr/testify/assert"
"github.com/yaoapp/kun/maps"
"github.com/yaoapp/yao/config"
)
func TestReadFile(t *testing.T) {
file := filepath.Join(config.Conf.Root, "tables", "env.tab.json")
defaults := map[string]interface{}{"PAGE_STATUS": "cured"}
content, err := ReadFile(file, defaults)
if err != nil {
t.Fatal(err)
}
res := maps.MapStr{}
err = jsoniter.Unmarshal(content, &res)
if err != nil {
t.Fatal(err)
}
res = res.Dot()
// utils.Dump(res)
assert.Equal(t, "::PET ADMIN", res.Get("name"))
assert.Equal(t, "20", res.Get("action.search.default.2"))
assert.Equal(t, "https://yaoapps.com", res.Get("layout.header.preset.import.operation.0.link"))
assert.Equal(t, "cured", res.Get("layout.table.operation.actions.2.action.Table.save.status"))
}