Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions bindparam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ import (
"testing"
"time"

"github.com/oapi-codegen/runtime/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/oapi-codegen/runtime/types"
)

// MockBinder is just an independent version of Binder that has the Bind implemented
Expand All @@ -45,7 +46,7 @@ func (d *MockBinder) Bind(src string) error {
}

func (d MockBinder) MarshalJSON() ([]byte, error) {
return json.Marshal(d.Time.Format(types.DateFormat))
return json.Marshal(d.Format(types.DateFormat))
}

func (d *MockBinder) UnmarshalJSON(data []byte) error {
Expand Down Expand Up @@ -539,7 +540,7 @@ func TestBindStyledParameterWithLocation(t *testing.T) {
Required: false,
})
assert.NoError(t, err)
assert.Equal(t, *&expectedObject, dstObject)
assert.EqualValues(t, expectedObject, dstObject)
})

t.Run("map", func(t *testing.T) {
Expand All @@ -555,6 +556,6 @@ func TestBindStyledParameterWithLocation(t *testing.T) {
Required: false,
})
assert.NoError(t, err)
assert.Equal(t, *&expectedMap, dstMap)
assert.EqualValues(t, expectedMap, dstMap)
})
}
7 changes: 4 additions & 3 deletions bindstring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (
"testing"
"time"

"github.com/oapi-codegen/runtime/types"
"github.com/stretchr/testify/assert"

"github.com/oapi-codegen/runtime/types"
)

func TestBindStringToObject(t *testing.T) {
Expand Down Expand Up @@ -197,10 +198,10 @@ func TestBindStringToObject(t *testing.T) {
// Checks whether a mock binder works and embedded types
var mockBinder MockBinder
assert.NoError(t, BindStringToObject(dateString, &mockBinder))
assert.EqualValues(t, dateString, mockBinder.Time.Format("2006-01-02"))
assert.EqualValues(t, dateString, mockBinder.Format("2006-01-02"))
var dstEmbeddedMockBinder EmbeddedMockBinder
assert.NoError(t, BindStringToObject(dateString, &dstEmbeddedMockBinder))
assert.EqualValues(t, dateString, dstEmbeddedMockBinder.Time.Format("2006-01-02"))
assert.EqualValues(t, dateString, dstEmbeddedMockBinder.Format("2006-01-02"))

// Checks UUID binding
uuidString := "bbca1470-5e1f-4c64-ba99-fa7a6d2687b0"
Expand Down
4 changes: 2 additions & 2 deletions types/date.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type Date struct {
}

func (d Date) MarshalJSON() ([]byte, error) {
return json.Marshal(d.Time.Format(DateFormat))
return json.Marshal(d.Format(DateFormat))
}

func (d *Date) UnmarshalJSON(data []byte) error {
Expand All @@ -30,7 +30,7 @@ func (d *Date) UnmarshalJSON(data []byte) error {
}

func (d Date) String() string {
return d.Time.Format(DateFormat)
return d.Format(DateFormat)
}

func (d *Date) UnmarshalText(data []byte) error {
Expand Down