Skip to content

Commit

Permalink
Upgrade gomock
Browse files Browse the repository at this point in the history
Doing so breaks a couple tests, so this PR fixes those as well.

Signed-off-by: Craig Jellick <[email protected]>
  • Loading branch information
cjellick committed Mar 27, 2023
1 parent 5856fe3 commit 7b488a3
Show file tree
Hide file tree
Showing 6 changed files with 138 additions and 143 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ require (
github.com/docker/cli v20.10.21+incompatible
github.com/docker/docker-credential-helpers v0.7.0
github.com/go-acme/lego/v4 v4.9.1
github.com/golang/mock v1.4.4
github.com/golang/mock v1.6.0
github.com/google/go-cmp v0.5.9
github.com/google/go-containerregistry v0.12.1
github.com/google/go-containerregistry/pkg/authn/kubernetes v0.0.0-20221213180026-23d895d08035
Expand Down
4 changes: 3 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,9 @@ github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFU
github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw=
github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
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/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
Expand Down Expand Up @@ -936,6 +937,7 @@ golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc
golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA=
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
Expand Down
9 changes: 2 additions & 7 deletions pkg/client/info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ package client_test

import (
"context"
"testing"

v12 "github.com/acorn-io/acorn/pkg/apis/api.acorn.io/v1"
"github.com/acorn-io/acorn/pkg/client"
"github.com/acorn-io/acorn/pkg/labels"
Expand All @@ -16,7 +18,6 @@ import (

// may want to use envtest instead
testcontrollerclient "sigs.k8s.io/controller-runtime/pkg/client/fake"
"testing"
)

func createMockedDefaultClient(t *testing.T, projectName string, namespace string) (client.DefaultClient, v12.InfoList, error) {
Expand Down Expand Up @@ -102,13 +103,10 @@ func TestMultiClientInfo(t *testing.T) {
ctrl := gomock.NewController(t)
mFactory := mocks.NewMockProjectClientFactory(ctrl)
mFactory.EXPECT().List(gomock.Any()).Return([]client.Client{&defaultClient1, &defaultClient2}, nil)
mFactory.EXPECT().DefaultProject().Return("test1")
projectMap := make(map[string]*client.DefaultClient)
projectMap["test1"] = &defaultClient1
projectMap["test2"] = &defaultClient2

mFactory.EXPECT().ForProject(gomock.Any(), gomock.Any()).DoAndReturn(func(ctx context.Context, projectName string) client.Client { return projectMap[projectName] })

mMultiClient := client.NewMultiClient("test1", "test1", mFactory)
infoResp, err := mMultiClient.Info(ctx)

Expand All @@ -133,13 +131,10 @@ func TestMultiClientFQDNClobberingInfo(t *testing.T) {
ctrl := gomock.NewController(t)
mFactory := mocks.NewMockProjectClientFactory(ctrl)
mFactory.EXPECT().List(gomock.Any()).Return([]client.Client{&defaultClient1, &defaultClient2}, nil)
mFactory.EXPECT().DefaultProject().Return("test1")
projectMap := make(map[string]*client.DefaultClient)
projectMap["test1"] = &defaultClient1
projectMap["acorn.io/jacob/test1"] = &defaultClient2

mFactory.EXPECT().ForProject(gomock.Any(), gomock.Any()).DoAndReturn(func(ctx context.Context, projectName string) client.Client { return projectMap[projectName] })

mMultiClient := client.NewMultiClient("test1", "test1", mFactory)
infoResp, err := mMultiClient.Info(ctx)

Expand Down
4 changes: 0 additions & 4 deletions pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ func TestAcornDNSStates(t *testing.T) {
ClusterDomains: []string{".custom.com"},
},
expectedClusterDomains: []string{".custom.com"},
prepare: func(f *mocks.MockReader) {
f.EXPECT().Get(gomock.Any(), gomock.Any(), gomock.Any()).Return(nil)
f.EXPECT().List(gomock.Any(), gomock.Any()).Return(nil)
},
},
}

Expand Down
19 changes: 10 additions & 9 deletions pkg/mocks/k8s/mock.go

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

Loading

0 comments on commit 7b488a3

Please sign in to comment.