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("../search.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(`#[label = "广告"]#`)
|
|
|
|
if adData.Exists() {
|
|
|
|
for _, result := range adData.Array() {
|
|
|
|
adDataList = append(adDataList, result.String())
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
t.Error(`expr error`)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-04 09:35:30 +00:00
|
|
|
if len(adDataList) == 1 {
|
2019-01-04 08:25:27 +00:00
|
|
|
t.Error("adDataList != 1")
|
|
|
|
t.Error(adDataList)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|