diff --git a/bindparam_test.go b/bindparam_test.go index 3028c8a7..eec3d3ad 100644 --- a/bindparam_test.go +++ b/bindparam_test.go @@ -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 @@ -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 { @@ -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) { @@ -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) }) } diff --git a/bindstring_test.go b/bindstring_test.go index d1ddf39d..d3c49096 100644 --- a/bindstring_test.go +++ b/bindstring_test.go @@ -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) { @@ -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" diff --git a/types/date.go b/types/date.go index 6ad852f6..6663bdc1 100644 --- a/types/date.go +++ b/types/date.go @@ -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 { @@ -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 {