Skip to content

Commit

Permalink
Add test case for not sent form field to default value specified
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmadSaeedGoda committed Sep 4, 2024
1 parent cf50cce commit b31017d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions binding/form_mapping_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ func TestMappingForm(t *testing.T) {
assert.Equal(t, 6, s.F)
}

func TestMappingFormFieldNotSent(t *testing.T) {
var s struct {
F string `form:"field,default=defVal"`
}
err := mapForm(&s, map[string][]string{})
require.NoError(t, err)
assert.Equal(t, "defVal", s.F)
}

func TestMappingFormWithEmptyToDefault(t *testing.T) {
var s struct {
F string `form:"field,default=DefVal"`
Expand Down

0 comments on commit b31017d

Please sign in to comment.