Skip to content

Commit

Permalink
test without options
Browse files Browse the repository at this point in the history
  • Loading branch information
syntaqx committed Jun 28, 2024
1 parent cbd4248 commit b9e8333
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions cookie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,28 @@ func TestSet(t *testing.T) {
t.Errorf("Expected cookie SameSite %d, got %d", options.SameSite, cookie.SameSite)
}
}

func TestSet_WithoutOptions(t *testing.T) {
_, err := http.NewRequest(http.MethodGet, "/", nil)
if err != nil {
t.Fatal(err)
}
w := httptest.NewRecorder()

name := "myCookie"
value := "myValue"

Set(w, name, value, nil)

// Get the response cookies
cookies := w.Result().Cookies()

// Check if the cookie was set correctly
if len(cookies) != 1 {
t.Errorf("Expected 1 cookie, got %d", len(cookies))
}
}

func TestGet(t *testing.T) {
r := httptest.NewRequest(http.MethodGet, "/", nil)
cookieName := "myCookie"
Expand Down

0 comments on commit b9e8333

Please sign in to comment.