ad_parser/parser_test.go

72 lines
1.2 KiB
Go
Raw Normal View History

2018-12-18 10:45:04 +00:00
package parser
import (
"encoding/json"
2018-12-19 09:51:39 +00:00
"log"
2018-12-18 10:45:04 +00:00
"testing"
)
func TestParser(t *testing.T) {
2018-12-19 09:51:39 +00:00
a := NewADParser(12)
2018-12-18 10:45:04 +00:00
data, err := json.Marshal(a)
if err != nil {
t.Error(err)
}
t.Error(string(data))
}
2018-12-19 09:51:39 +00:00
type Toutiao struct {
Parser
// Url string // "amqp://aso:Wtu(!Ft559W%>mHK~i@172.19.30.60:5672/test_adspider"
}
func (tt *Toutiao) GetSpiderID() int {
return 1000073
}
func (tt *Toutiao) ToDoParser(adstring string) (string, error) {
adparser := NewADParser(tt.GetSpiderID())
log.Println(adparser)
data, err := adparser.ToJSON()
if err != nil {
panic(err)
}
log.Println(string(data))
return "", nil
}
func TestParserToutiao(t *testing.T) {
tt := Toutiao{}
2018-12-19 10:28:06 +00:00
// tt.ConfigLogDB("logdb.yaml")
2018-12-19 09:51:39 +00:00
tt.ConfigQueue("queue.yaml")
2018-12-19 10:28:06 +00:00
// ADParserServer(&tt)
2018-12-19 10:12:01 +00:00
t.Error("")
2018-12-19 09:51:39 +00:00
}
func TestMQ(t *testing.T) {
var l []interface{}
data := make(map[string]interface{})
data["fuck"] = "123"
l = append(l, data)
pjson, err := json.Marshal(&l)
if err != nil {
panic(err)
}
t.Error(string(pjson))
que := NewQueue("amqp://spider:spider@172.16.6.109:5672/test_adspider", "ad_process", "CN")
que.Push(pjson)
// msgs, _, err := ch.Get("ad_process:CN", true)
// if err != nil {
// panic(err)
// }
// log.Println(string(msgs.Body))
}