github.com/MontFerret/ferret@v0.18.0/pkg/drivers/helpers_test.go (about) 1 package drivers_test 2 3 import ( 4 "testing" 5 "time" 6 7 . "github.com/smartystreets/goconvey/convey" 8 9 "github.com/MontFerret/ferret/pkg/drivers" 10 ) 11 12 func TestSetDefaultParams(t *testing.T) { 13 Convey("Should take values from Options if not present in Params", t, func() { 14 opts := &drivers.Options{ 15 Name: "Test", 16 UserAgent: "Mozilla", 17 Headers: drivers.NewHTTPHeadersWith(map[string][]string{ 18 "Accept": {"application/json"}, 19 }), 20 Cookies: drivers.NewHTTPCookiesWith(map[string]drivers.HTTPCookie{ 21 "Session": drivers.HTTPCookie{ 22 Name: "Session", 23 Value: "fsfsdfsd", 24 Path: "", 25 Domain: "", 26 Expires: time.Time{}, 27 MaxAge: 0, 28 Secure: false, 29 HTTPOnly: false, 30 SameSite: 0, 31 }, 32 }), 33 } 34 35 params := drivers.SetDefaultParams(opts, drivers.Params{}) 36 37 So(params.UserAgent, ShouldEqual, opts.UserAgent) 38 So(params.Headers, ShouldNotBeNil) 39 So(params.Cookies, ShouldNotBeNil) 40 }) 41 }