package core import ( "testing" "github.com/stretchr/testify/assert" "github.com/yaoapp/kun/any" "github.com/yaoapp/yao/config" "github.com/yaoapp/yao/test" ) func TestPageExec(t *testing.T) { prepare(t) defer clean() page := testPage(t) request := &Request{ URL: ReqeustURL{Path: "/test/path"}, Query: map[string][]string{"show": {"yes"}}, Locale: "zh-CN", Theme: "dark", } data, err := page.Exec(request) if err != nil { t.Fatalf("Exec error: %v", err) } assert.NotEmpty(t, data) res := any.Of(data).Map().Dot() assert.Equal(t, "yes", res.Get("array[3][0].query")) assert.Equal(t, "Article Search", res.Get("articles.data[0].description")) assert.Equal(t, "/test/path", res.Get("url.path")) } func prepare(t *testing.T) { test.Prepare(t, config.Conf, "YAO_TEST_BUILDER_APPLICATION") } func clean() { test.Clean() } func testPage(t *testing.T) *Page { page := &Page{ Name: "test", Route: "test", Document: []byte(`