Added user-agent test, Fixed failing test
This commit is contained in:
parent
85597219e6
commit
86d4e80596
@ -1,6 +1,7 @@
|
||||
package geziyor_test
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/fortytw2/leaktest"
|
||||
@ -10,6 +11,7 @@ import (
|
||||
"github.com/geziyor/geziyor/client"
|
||||
"github.com/geziyor/geziyor/export"
|
||||
"github.com/geziyor/geziyor/metrics"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
@ -25,6 +27,19 @@ func TestSimple(t *testing.T) {
|
||||
}).Start()
|
||||
}
|
||||
|
||||
func TestUserAgent(t *testing.T) {
|
||||
geziyor.NewGeziyor(&geziyor.Options{
|
||||
StartURLs: []string{"https://httpbin.org/anything"},
|
||||
ParseFunc: func(g *geziyor.Geziyor, r *client.Response) {
|
||||
var data map[string]interface{}
|
||||
err := json.Unmarshal(r.Body, &data)
|
||||
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, client.DefaultUserAgent, data["headers"].(map[string]interface{})["User-Agent"])
|
||||
},
|
||||
}).Start()
|
||||
}
|
||||
|
||||
func TestCache(t *testing.T) {
|
||||
defer leaktest.Check(t)()
|
||||
geziyor.NewGeziyor(&geziyor.Options{
|
||||
@ -71,7 +86,6 @@ func TestAllLinks(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipping test in short mode.")
|
||||
}
|
||||
defer leaktest.Check(t)()
|
||||
|
||||
geziyor.NewGeziyor(&geziyor.Options{
|
||||
AllowedDomains: []string{"books.toscrape.com"},
|
||||
|
Loading…
x
Reference in New Issue
Block a user