Set cookie test
This commit is contained in:
parent
53a91d63d6
commit
242b025c9a
@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/geziyor/geziyor/cache/diskcache"
|
"github.com/geziyor/geziyor/cache/diskcache"
|
||||||
"github.com/geziyor/geziyor/client"
|
"github.com/geziyor/geziyor/client"
|
||||||
"github.com/geziyor/geziyor/export"
|
"github.com/geziyor/geziyor/export"
|
||||||
|
"github.com/geziyor/geziyor/internal"
|
||||||
"github.com/geziyor/geziyor/metrics"
|
"github.com/geziyor/geziyor/metrics"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"net/http"
|
"net/http"
|
||||||
@ -132,6 +133,27 @@ func TestGetRendered(t *testing.T) {
|
|||||||
}).Start()
|
}).Start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestGetRenderedCookie(t *testing.T) {
|
||||||
|
testServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
_, _ = w.Write([]byte(r.Header.Get("Cookie")))
|
||||||
|
}))
|
||||||
|
geziyor.NewGeziyor(&geziyor.Options{
|
||||||
|
StartRequestsFunc: func(g *geziyor.Geziyor) {
|
||||||
|
req, err := client.NewRequest("GET", testServer.URL, nil)
|
||||||
|
if err != nil {
|
||||||
|
internal.Logger.Printf("Request creating error %v\n", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
req.Header.Set("Cookie", "key=value")
|
||||||
|
req.Rendered = true
|
||||||
|
g.Do(req, g.Opt.ParseFunc)
|
||||||
|
},
|
||||||
|
ParseFunc: func(g *geziyor.Geziyor, r *client.Response) {
|
||||||
|
assert.Contains(t, string(r.Body), "key=value")
|
||||||
|
},
|
||||||
|
}).Start()
|
||||||
|
}
|
||||||
|
|
||||||
// Run chrome headless instance to test this
|
// Run chrome headless instance to test this
|
||||||
//func TestGetRenderedRemoteAllocator(t *testing.T) {
|
//func TestGetRenderedRemoteAllocator(t *testing.T) {
|
||||||
// geziyor.NewGeziyor(&geziyor.Options{
|
// geziyor.NewGeziyor(&geziyor.Options{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user