Skip to content

Commit 5bb2934

Browse files
mromaszewiczmarcinromaszewicz
andauthored
Fix linter errors (#85)
We have some old code which started to fail lint due to the linter being pedantic. Fix lint issues. Co-authored-by: marcinromaszewicz <marcinromaszewicz@deepmap.ai>
1 parent 179c5e9 commit 5bb2934

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

bindparam_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ import (
2121
"testing"
2222
"time"
2323

24-
"github.com/oapi-codegen/runtime/types"
2524
"github.com/stretchr/testify/assert"
2625
"github.com/stretchr/testify/require"
26+
27+
"github.com/oapi-codegen/runtime/types"
2728
)
2829

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

4748
func (d MockBinder) MarshalJSON() ([]byte, error) {
48-
return json.Marshal(d.Time.Format(types.DateFormat))
49+
return json.Marshal(d.Format(types.DateFormat))
4950
}
5051

5152
func (d *MockBinder) UnmarshalJSON(data []byte) error {
@@ -539,7 +540,7 @@ func TestBindStyledParameterWithLocation(t *testing.T) {
539540
Required: false,
540541
})
541542
assert.NoError(t, err)
542-
assert.Equal(t, *&expectedObject, dstObject)
543+
assert.EqualValues(t, expectedObject, dstObject)
543544
})
544545

545546
t.Run("map", func(t *testing.T) {
@@ -555,6 +556,6 @@ func TestBindStyledParameterWithLocation(t *testing.T) {
555556
Required: false,
556557
})
557558
assert.NoError(t, err)
558-
assert.Equal(t, *&expectedMap, dstMap)
559+
assert.EqualValues(t, expectedMap, dstMap)
559560
})
560561
}

bindstring_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ import (
1919
"testing"
2020
"time"
2121

22-
"github.com/oapi-codegen/runtime/types"
2322
"github.com/stretchr/testify/assert"
23+
24+
"github.com/oapi-codegen/runtime/types"
2425
)
2526

2627
func TestBindStringToObject(t *testing.T) {
@@ -197,10 +198,10 @@ func TestBindStringToObject(t *testing.T) {
197198
// Checks whether a mock binder works and embedded types
198199
var mockBinder MockBinder
199200
assert.NoError(t, BindStringToObject(dateString, &mockBinder))
200-
assert.EqualValues(t, dateString, mockBinder.Time.Format("2006-01-02"))
201+
assert.EqualValues(t, dateString, mockBinder.Format("2006-01-02"))
201202
var dstEmbeddedMockBinder EmbeddedMockBinder
202203
assert.NoError(t, BindStringToObject(dateString, &dstEmbeddedMockBinder))
203-
assert.EqualValues(t, dateString, dstEmbeddedMockBinder.Time.Format("2006-01-02"))
204+
assert.EqualValues(t, dateString, dstEmbeddedMockBinder.Format("2006-01-02"))
204205

205206
// Checks UUID binding
206207
uuidString := "bbca1470-5e1f-4c64-ba99-fa7a6d2687b0"

types/date.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ type Date struct {
1212
}
1313

1414
func (d Date) MarshalJSON() ([]byte, error) {
15-
return json.Marshal(d.Time.Format(DateFormat))
15+
return json.Marshal(d.Format(DateFormat))
1616
}
1717

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

3232
func (d Date) String() string {
33-
return d.Time.Format(DateFormat)
33+
return d.Format(DateFormat)
3434
}
3535

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

0 commit comments

Comments
 (0)