From 7f20464619713415cfbf6d2da226e7568188d3e8 Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Fri, 13 Oct 2023 12:33:14 +0100 Subject: [PATCH] feat(deps)!: switch to Uber's maintained fork of gomock --- Makefile | 3 ++- go.mod | 4 ++-- go.sum | 32 ++++---------------------------- mock/runner.go | 24 ++++++++++++++---------- runner.go | 2 +- ssh_cli_test.go | 2 +- sudo_test.go | 2 +- testing_test.go | 2 +- 8 files changed, 26 insertions(+), 45 deletions(-) diff --git a/Makefile b/Makefile index 0b986b9..6f7c9fd 100644 --- a/Makefile +++ b/Makefile @@ -47,7 +47,7 @@ $(eval $(call tool,gofumpt,mvdan.cc/gofumpt@latest)) $(eval $(call tool,goimports,golang.org/x/tools/cmd/goimports@latest)) $(eval $(call tool,golangci-lint,github.com/golangci/golangci-lint/cmd/golangci-lint@v1.54)) $(eval $(call tool,gomod,github.com/Helcaraxan/gomod@latest)) -$(eval $(call tool,mockgen,github.com/golang/mock/mockgen@v1.6.0)) +$(eval $(call tool,mockgen,go.uber.org/mock/mockgen@v0.3.0)) .PHONY: tools tools: $(TOOLS) @@ -91,6 +91,7 @@ bench: .PHONY: generate generate: $(TOOLDIR)/mockgen + mockgen --version go generate ./... .PHONY: check-generate diff --git a/go.mod b/go.mod index 5235cf6..66ce650 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module github.com/krystal/go-runner go 1.18 require ( - github.com/golang/mock v1.6.0 - github.com/romdo/gomockctx v0.1.0 + github.com/romdo/gomockctx v0.2.0 github.com/stretchr/testify v1.7.1 + go.uber.org/mock v0.3.0 ) require ( diff --git a/go.sum b/go.sum index 0f2a426..3fa987d 100644 --- a/go.sum +++ b/go.sum @@ -1,39 +1,15 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/romdo/gomockctx v0.1.0 h1:pkizAatykBP0gmtQs9wMGYPBUlSK0dmLl+O3N9aWd7k= -github.com/romdo/gomockctx v0.1.0/go.mod h1:t1xklNc2fVZ7d9S7WOZuXM1ytnPh6nXn5WyZK7XskVs= +github.com/romdo/gomockctx v0.2.0 h1:yNT6hfBVMDemaqQlbhvUV/kNYawP93vPECWVpTU3l84= +github.com/romdo/gomockctx v0.2.0/go.mod h1:Mr+f54zpuXT1rEUxpwF6OfkpY/idEbkBk3wkmRJcPJ8= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +go.uber.org/mock v0.3.0 h1:3mUxI1No2/60yUYax92Pt8eNOEecx2D3lcXZh2NEZJo= +go.uber.org/mock v0.3.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/mock/runner.go b/mock/runner.go index 5248829..cafdde8 100644 --- a/mock/runner.go +++ b/mock/runner.go @@ -1,6 +1,10 @@ // Code generated by MockGen. DO NOT EDIT. // Source: runner.go - +// +// Generated by this command: +// +// mockgen -source=runner.go -destination=mock/runner.go +// // Package mock_runner is a generated GoMock package. package mock_runner @@ -9,7 +13,7 @@ import ( io "io" reflect "reflect" - gomock "github.com/golang/mock/gomock" + gomock "go.uber.org/mock/gomock" ) // MockRunner is a mock of Runner interface. @@ -38,7 +42,7 @@ func (m *MockRunner) EXPECT() *MockRunnerMockRecorder { // Env mocks base method. func (m *MockRunner) Env(env ...string) { m.ctrl.T.Helper() - varargs := []interface{}{} + varargs := []any{} for _, a := range env { varargs = append(varargs, a) } @@ -46,7 +50,7 @@ func (m *MockRunner) Env(env ...string) { } // Env indicates an expected call of Env. -func (mr *MockRunnerMockRecorder) Env(env ...interface{}) *gomock.Call { +func (mr *MockRunnerMockRecorder) Env(env ...any) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Env", reflect.TypeOf((*MockRunner)(nil).Env), env...) } @@ -54,7 +58,7 @@ func (mr *MockRunnerMockRecorder) Env(env ...interface{}) *gomock.Call { // Run mocks base method. func (m *MockRunner) Run(stdin io.Reader, stdout, stderr io.Writer, command string, args ...string) error { m.ctrl.T.Helper() - varargs := []interface{}{stdin, stdout, stderr, command} + varargs := []any{stdin, stdout, stderr, command} for _, a := range args { varargs = append(varargs, a) } @@ -64,16 +68,16 @@ func (m *MockRunner) Run(stdin io.Reader, stdout, stderr io.Writer, command stri } // Run indicates an expected call of Run. -func (mr *MockRunnerMockRecorder) Run(stdin, stdout, stderr, command interface{}, args ...interface{}) *gomock.Call { +func (mr *MockRunnerMockRecorder) Run(stdin, stdout, stderr, command any, args ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{stdin, stdout, stderr, command}, args...) + varargs := append([]any{stdin, stdout, stderr, command}, args...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Run", reflect.TypeOf((*MockRunner)(nil).Run), varargs...) } // RunContext mocks base method. func (m *MockRunner) RunContext(ctx context.Context, stdin io.Reader, stdout, stderr io.Writer, command string, args ...string) error { m.ctrl.T.Helper() - varargs := []interface{}{ctx, stdin, stdout, stderr, command} + varargs := []any{ctx, stdin, stdout, stderr, command} for _, a := range args { varargs = append(varargs, a) } @@ -83,8 +87,8 @@ func (m *MockRunner) RunContext(ctx context.Context, stdin io.Reader, stdout, st } // RunContext indicates an expected call of RunContext. -func (mr *MockRunnerMockRecorder) RunContext(ctx, stdin, stdout, stderr, command interface{}, args ...interface{}) *gomock.Call { +func (mr *MockRunnerMockRecorder) RunContext(ctx, stdin, stdout, stderr, command any, args ...any) *gomock.Call { mr.mock.ctrl.T.Helper() - varargs := append([]interface{}{ctx, stdin, stdout, stderr, command}, args...) + varargs := append([]any{ctx, stdin, stdout, stderr, command}, args...) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RunContext", reflect.TypeOf((*MockRunner)(nil).RunContext), varargs...) } diff --git a/runner.go b/runner.go index a8c40ce..2e29890 100644 --- a/runner.go +++ b/runner.go @@ -14,7 +14,7 @@ import ( "os/exec" ) -//go:generate go run github.com/golang/mock/mockgen@v1.6.0 -source=$GOFILE -destination=mock/${GOFILE} +//go:generate mockgen -source=$GOFILE -destination=mock/${GOFILE} // Runner is the interface that all runner structs implements. It makes it easy // to replace the underlying command runner with a mock for testing, or a diff --git a/ssh_cli_test.go b/ssh_cli_test.go index 488abc4..7f7eb5c 100644 --- a/ssh_cli_test.go +++ b/ssh_cli_test.go @@ -7,10 +7,10 @@ import ( "io" "testing" - "github.com/golang/mock/gomock" mock_runner "github.com/krystal/go-runner/mock" "github.com/romdo/gomockctx" "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" ) func TestSSHCLI_Run(t *testing.T) { diff --git a/sudo_test.go b/sudo_test.go index 8241137..29e3e03 100644 --- a/sudo_test.go +++ b/sudo_test.go @@ -7,10 +7,10 @@ import ( "io" "testing" - "github.com/golang/mock/gomock" mock_runner "github.com/krystal/go-runner/mock" "github.com/romdo/gomockctx" "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" ) func TestSudo_Run(t *testing.T) { diff --git a/testing_test.go b/testing_test.go index 6dfb01c..9be111d 100644 --- a/testing_test.go +++ b/testing_test.go @@ -8,10 +8,10 @@ import ( "io" "testing" - "github.com/golang/mock/gomock" mock_runner "github.com/krystal/go-runner/mock" "github.com/romdo/gomockctx" "github.com/stretchr/testify/assert" + "go.uber.org/mock/gomock" ) type fakeTestingT struct {