diff options
Diffstat (limited to 'pkg/web/cookie/option_test.go')
| -rw-r--r-- | pkg/web/cookie/option_test.go | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/pkg/web/cookie/option_test.go b/pkg/web/cookie/option_test.go deleted file mode 100644 index 97913ba..0000000 --- a/pkg/web/cookie/option_test.go +++ /dev/null @@ -1,53 +0,0 @@ -package cookie - -import ( - "net/http" - "testing" - "time" - - "github.com/stretchr/testify/assert" -) - -func TestOption(t *testing.T) { - t.Run("WithPath", func(t *testing.T) { - assert.Equal(t, "/blah", New("name", "value", WithPath("/blah")).Path) - }) - - t.Run("WithHttpOnly", func(t *testing.T) { - assert.False(t, New("x", "v", WithHttpOnly(false)).HttpOnly) - assert.True(t, New("x", "v", WithHttpOnly(true)).HttpOnly) - }) - - t.Run("WithSecure", func(t *testing.T) { - assert.False(t, New("x", "v", WithSecure(false)).Secure) - assert.True(t, New("x", "v", WithSecure(true)).Secure) - }) - - t.Run("WithDomain", func(t *testing.T) { - assert.Equal(t, "example.com", New("x", "v", WithDomain("example.com")).Domain) - }) - - t.Run("WithSameSite", func(t *testing.T) { - assert.Equal(t, http.SameSiteLaxMode, New("x", "v", WithSameSite(http.SameSiteLaxMode)).SameSite) - assert.Equal(t, http.SameSiteStrictMode, New("x", "v", WithSameSite(http.SameSiteStrictMode)).SameSite) - assert.Equal(t, http.SameSiteNoneMode, New("x", "v", WithSameSite(http.SameSiteNoneMode)).SameSite) - }) - - t.Run("WithExpiration", func(t *testing.T) { - now := time.Now() - - t.Run("with future time", func(t *testing.T) { - expires := now.Add(1 * time.Second) - cookie := New("x", "v", WithExpiration(expires)) - assert.Equal(t, expires, cookie.Expires) - assert.Equal(t, 1, cookie.MaxAge) - }) - - t.Run("with past time", func(t *testing.T) { - expires := now.Add(-1 * time.Second) - cookie := New("x", "v", WithExpiration(expires)) - assert.Equal(t, expires, cookie.Expires) - assert.Equal(t, -1, cookie.MaxAge) - }) - }) -} |
