Skip to content

Commit

Permalink
attempt to complete test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
syntaqx committed Jun 30, 2024
1 parent fcad907 commit c276722
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 @@ -425,6 +425,28 @@ func TestPopulateFromCookies_InvalidIntSliceValue(t *testing.T) {
}
}

func TestPopulateFromCookies_UnexpectedSliceType(t *testing.T) {
r := httptest.NewRequest(http.MethodGet, "/", nil)
r.AddCookie(&http.Cookie{
Name: "mySliceCookie",
Value: "val1,val2,val3",
})

type MyStruct struct {
StringSlice []bool `cookie:"mySliceCookie"`
}

dest := &MyStruct{}
err := PopulateFromCookies(r, dest)
if err == nil {
t.Error("Expected error, got nil")
}

if _, ok := err.(*UnsupportedTypeError); !ok {
t.Errorf("Expected error of type UnsupportedTypeError, got %T", err)
}
}

func TestPopulateFromCookies_InvalidUUIDValue(t *testing.T) {
r := httptest.NewRequest(http.MethodGet, "/", nil)
r.AddCookie(&http.Cookie{
Expand Down

0 comments on commit c276722

Please sign in to comment.