toutiao/splash/splash_test.go
2019-01-04 16:25:27 +08:00

39 lines
632 B
Go

package main
import (
"io/ioutil"
"testing"
"474420502.top/eson/gjson"
)
func TestTaskEx_Execute(t *testing.T) {
data, err := ioutil.ReadFile("../splash.json")
if err != nil {
panic(err)
}
var adDataList []string
if gjson.Valid(string(data)) {
P := gjson.Parse(string(data))
data := P.Get(`data`)
if data.Exists() {
adData := data.Get(`splash`)
if adData.Exists() {
for _, result := range adData.Array() {
adDataList = append(adDataList, result.String())
}
} else {
t.Error(`expr error`)
}
}
}
if len(adDataList) != 1 {
t.Error("adDataList != 1")
t.Error(adDataList)
}
}