Skip to content

Commit

Permalink
Added user-agent test, Fixed failing test
Browse files Browse the repository at this point in the history
  • Loading branch information
musabgultekin committed Aug 5, 2019
1 parent 8559721 commit 86d4e80
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion geziyor_test.go
@@ -1,6 +1,7 @@
package geziyor_test

import (
"encoding/json"
"fmt"
"github.com/PuerkitoBio/goquery"
"github.com/fortytw2/leaktest"
Expand All @@ -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"
Expand All @@ -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{
Expand Down Expand Up @@ -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"},
Expand Down

0 comments on commit 86d4e80

Please sign in to comment.