Skip to content

Commit

Permalink
chore(deps): downgrading to go 1.24 (#127)
Browse files Browse the repository at this point in the history
* downgrading to 1.23

* rebase

* mock filter tests

* filter test values
  • Loading branch information
Jacobbrewer1 authored Feb 25, 2025
1 parent 1cef1bf commit 9a3b4f6
Show file tree
Hide file tree
Showing 8 changed files with 167 additions and 10 deletions.
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module github.com/jacobbrewer1/patcher

go 1.24
go 1.23

toolchain go1.24.0
toolchain go1.23.4

require (
github.com/gorilla/mux v1.8.1
github.com/stretchr/testify v1.10.0
github.com/vektra/mockery/v2 v2.52.3
github.com/vektra/mockery/v2 v2.52.1
)

require (
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
github.com/vektra/mockery/v2 v2.52.3 h1:lInrh+OuJu3dY/UPFvdFmJ/lsscEnUFrTmagcRJKoWU=
github.com/vektra/mockery/v2 v2.52.3/go.mod h1:zGDY/f6bip0Yh13GQ5j7xa43fuEoYBa4ICHEaihisHw=
github.com/vektra/mockery/v2 v2.52.1 h1:ejpWJSsInVNsFUvaAX4szecrpYxErN+Ny5X+0RXBP+s=
github.com/vektra/mockery/v2 v2.52.1/go.mod h1:ZJeus9igl4Uf8FGLwXZgtCnp2XUDFD9Mkipi7nsObq0=
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
golang.org/x/exp v0.0.0-20250210185358-939b2ce775ac h1:l5+whBCLH3iH2ZNHYLbAe58bo7yrN4mVcnkHDYz5vvs=
Expand Down
84 changes: 84 additions & 0 deletions mock_Filter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

73 changes: 73 additions & 0 deletions sql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,79 @@ func (s *newSQLPatchSuite) TestNewSQLPatch_Success() {
s.Equal([]any{1, "test"}, patch.args)
}

func (s *newSQLPatchSuite) TestNewSQLPatch_Success_Filter_Where() {
type testObj struct {
Id *int `db:"id_tag"`
Name *string `db:"name_tag"`
}

obj := testObj{
Id: ptr(1),
Name: ptr("test"),
}

mf := NewMockFilter(s.T())
mf.On("Where").Return("test_where = ? and arg2_val = ?", []any{"arg1", "arg2"})

patch := NewSQLPatch(obj, WithWhere(mf))

s.Equal([]string{"id_tag = ?", "name_tag = ?"}, patch.fields)
s.Equal([]any{1, "test"}, patch.args)

s.Equal("AND test_where = ? and arg2_val = ?\n", patch.whereSql.String())
s.Equal([]any{"arg1", "arg2"}, patch.whereArgs)
}

func (s *newSQLPatchSuite) TestNewSQLPatch_Success_Filter_Join() {
type testObj struct {
Id *int `db:"id_tag"`
Name *string `db:"name_tag"`
}

obj := testObj{
Id: ptr(1),
Name: ptr("test"),
}

mf := NewMockFilter(s.T())
mf.On("Join").Return("JOIN table2 ON table1.id = table2.id and arg2_val = ?", []any{"arg1"})

patch := NewSQLPatch(obj, WithJoin(mf))

s.Equal([]string{"id_tag = ?", "name_tag = ?"}, patch.fields)
s.Equal([]any{1, "test"}, patch.args)

s.Equal("JOIN table2 ON table1.id = table2.id and arg2_val = ?\n", patch.joinSql.String())
s.Equal([]any{"arg1"}, patch.joinArgs)
}

func (s *newSQLPatchSuite) TestNewSQLPatch_Success_Filter_JoinerAndWhere() {
type testObj struct {
Id *int `db:"id_tag"`
Name *string `db:"name_tag"`
}

obj := testObj{
Id: ptr(1),
Name: ptr("test"),
}

mf := NewMockFilter(s.T())
mf.On("Join").Return("JOIN table2 ON table1.id = table2.id and arg2_val = ?", []any{"arg1"})
mf.On("Where").Return("where", []any{"arg1", "arg2"})

patch := NewSQLPatch(obj, WithFilter(mf))

s.Equal([]string{"id_tag = ?", "name_tag = ?"}, patch.fields)
s.Equal([]any{1, "test"}, patch.args)

s.Equal("JOIN table2 ON table1.id = table2.id and arg2_val = ?\n", patch.joinSql.String())
s.Equal([]any{"arg1"}, patch.joinArgs)

s.Equal("AND where\n", patch.whereSql.String())
s.Equal([]any{"arg1", "arg2"}, patch.whereArgs)
}

func (s *newSQLPatchSuite) TestNewSQLPatch_Success_MultiFilter() {
type testObj struct {
Id *int `db:"id_tag"`
Expand Down
2 changes: 1 addition & 1 deletion vendor/github.com/vektra/mockery/v2/CONTRIBUTING.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/vektra/mockery/v2/Dockerfile

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/vektra/mockery/v2/mockery-tools.env

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ github.com/stretchr/testify/suite
# github.com/subosito/gotenv v1.6.0
## explicit; go 1.18
github.com/subosito/gotenv
# github.com/vektra/mockery/v2 v2.52.3
## explicit; go 1.24
# github.com/vektra/mockery/v2 v2.52.1
## explicit; go 1.23
github.com/vektra/mockery/v2
github.com/vektra/mockery/v2/cmd
github.com/vektra/mockery/v2/pkg
Expand Down

0 comments on commit 9a3b4f6

Please sign in to comment.