toutiao/splash/splash_test.go

39 lines
632 B
Go
Raw Normal View History

2019-01-04 08:25:27 +00:00
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)
}
}