Skip to content

Commit

Permalink
chore: use uber-go/mock (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
keroxp authored Jul 11, 2024
1 parent 196daa5 commit 51fc11a
Show file tree
Hide file tree
Showing 22 changed files with 25 additions and 40 deletions.
5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
MOCKGEN := go run github.com/golang/mock/mockgen@v1.6.0
MOCKGEN := go run go.uber.org/mock/mockgen
.PHONY: test
test:
go test ./... -coverprofile=coverage.txt -covermode=count
Expand All @@ -9,7 +9,8 @@ push-test-container: test-container
docker push loilodev/http-server:latest
version:
go run cli/cage/main.go -v | cut -f 3 -d ' '
mocks: mocks/mock_awsiface/iface.go \
mocks: go.sum \
mocks/mock_awsiface/iface.go \
mocks/mock_types/iface.go \
mocks/mock_upgrade/upgrade.go \
mocks/mock_task/task.go \
Expand Down
2 changes: 1 addition & 1 deletion cli/cage/commands/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"strings"
"testing"

"github.com/golang/mock/gomock"
"github.com/loilo-inc/canarycage/env"
"github.com/loilo-inc/canarycage/mocks/mock_types"
"github.com/loilo-inc/canarycage/test"
"github.com/loilo-inc/canarycage/types"
"github.com/stretchr/testify/assert"
"github.com/urfave/cli/v2"
"go.uber.org/mock/gomock"
)

func TestCommands(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion cli/cage/commands/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package commands_test
import (
"testing"

"github.com/golang/mock/gomock"
"github.com/loilo-inc/canarycage/cli/cage/commands"
"github.com/loilo-inc/canarycage/cli/cage/upgrade"
"github.com/loilo-inc/canarycage/mocks/mock_upgrade"
"github.com/stretchr/testify/assert"
"github.com/urfave/cli/v2"
"go.uber.org/mock/gomock"
)

func TestUpgrade(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ require (
github.com/aws/aws-sdk-go-v2/service/ec2 v1.161.4
github.com/aws/aws-sdk-go-v2/service/ecs v1.41.11
github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2 v1.31.1
github.com/golang/mock v1.6.0
github.com/google/go-github/v62 v62.0.0
github.com/google/uuid v1.6.0
github.com/jarcoal/httpmock v1.3.1
github.com/stretchr/testify v1.9.0
github.com/urfave/cli/v2 v2.27.2
go.uber.org/mock v0.4.0
)

require github.com/google/go-querystring v1.1.0 // indirect
Expand Down
20 changes: 2 additions & 18 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
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/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
Expand Down Expand Up @@ -116,38 +114,24 @@ github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI=
github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1/go.mod h1:Ohn+xnUBiLI6FVj/9LpzZWtj1/D6lUovWYBkxHVV3aM=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.uber.org/mock v0.4.0 h1:VcM4ZOtdbR4f6VXfiOpwpVJDL6lCReaZ6mw31wqh7KU=
go.uber.org/mock v0.4.0/go.mod h1:a6FSlNadKUHUa9IP5Vyt1zh4fC7uAwxMutEAscFbkZc=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
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-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
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-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
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/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/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.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
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-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 h1:+cNy6SZtPcJQH3LJVLOSmiC7MMxXNOb3PU/VUEz+EhU=
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028/go.mod h1:NDW/Ps6MPRej6fsCIbMTohpP40sJ/P/vI1MoTEGwX90=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
Expand Down
2 changes: 1 addition & 1 deletion mocks/mock_awsiface/iface.go

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

2 changes: 1 addition & 1 deletion mocks/mock_rollout/executor.go

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

2 changes: 1 addition & 1 deletion mocks/mock_task/factory.go

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

2 changes: 1 addition & 1 deletion mocks/mock_task/task.go

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

2 changes: 1 addition & 1 deletion mocks/mock_taskset/taskset.go

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

2 changes: 1 addition & 1 deletion mocks/mock_types/iface.go

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

2 changes: 1 addition & 1 deletion mocks/mock_upgrade/upgrade.go

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

2 changes: 1 addition & 1 deletion rollout/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ecs"
ecstypes "github.com/aws/aws-sdk-go-v2/service/ecs/types"
"github.com/golang/mock/gomock"
"github.com/loilo-inc/canarycage/env"
"github.com/loilo-inc/canarycage/key"
"github.com/loilo-inc/canarycage/mocks/mock_awsiface"
Expand All @@ -17,6 +16,7 @@ import (
"github.com/loilo-inc/canarycage/types"
"github.com/loilo-inc/logos/di"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

func TestNewExecutor(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion rollout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
ecstypes "github.com/aws/aws-sdk-go-v2/service/ecs/types"
alb "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
albtypes "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
"github.com/golang/mock/gomock"
"github.com/loilo-inc/canarycage/env"
"github.com/loilo-inc/canarycage/key"
"github.com/loilo-inc/canarycage/mocks/mock_awsiface"
Expand All @@ -19,6 +18,7 @@ import (
"github.com/loilo-inc/canarycage/types"
"github.com/loilo-inc/logos/di"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

// fake integration test with test.MockContext
Expand Down
2 changes: 1 addition & 1 deletion run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ecs"
ecstypes "github.com/aws/aws-sdk-go-v2/service/ecs/types"
"github.com/golang/mock/gomock"
cage "github.com/loilo-inc/canarycage"
"github.com/loilo-inc/canarycage/env"
"github.com/loilo-inc/canarycage/key"
Expand All @@ -16,6 +15,7 @@ import (
"github.com/loilo-inc/canarycage/types"
"github.com/loilo-inc/logos/di"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

func TestCage_Run(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion task/alb_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ import (
ecstypes "github.com/aws/aws-sdk-go-v2/service/ecs/types"
elbv2 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
elbv2types "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2/types"
"github.com/golang/mock/gomock"
"github.com/loilo-inc/canarycage/env"
"github.com/loilo-inc/canarycage/key"
"github.com/loilo-inc/canarycage/mocks/mock_awsiface"
"github.com/loilo-inc/canarycage/test"
"github.com/loilo-inc/logos/di"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

func TestNewAlbTask(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion task/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ecs"
ecstypes "github.com/aws/aws-sdk-go-v2/service/ecs/types"
"github.com/golang/mock/gomock"
"github.com/loilo-inc/canarycage/env"
"github.com/loilo-inc/canarycage/key"
"github.com/loilo-inc/canarycage/mocks/mock_awsiface"
"github.com/loilo-inc/canarycage/mocks/mock_types"
"github.com/loilo-inc/canarycage/test"
"github.com/loilo-inc/logos/di"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

func TestCommon_Start(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion task/simple_task_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/ecs"
ecstypes "github.com/aws/aws-sdk-go-v2/service/ecs/types"
"github.com/golang/mock/gomock"
"github.com/loilo-inc/canarycage/key"
"github.com/loilo-inc/canarycage/mocks/mock_awsiface"
"github.com/loilo-inc/canarycage/mocks/mock_types"
"github.com/loilo-inc/canarycage/test"
"github.com/loilo-inc/logos/di"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

func TestNewSimpleTask(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion task_definition_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ import (

"github.com/aws/aws-sdk-go-v2/service/ecs"
ecstypes "github.com/aws/aws-sdk-go-v2/service/ecs/types"
"github.com/golang/mock/gomock"
"github.com/loilo-inc/canarycage/env"
"github.com/loilo-inc/canarycage/key"
"github.com/loilo-inc/canarycage/mocks/mock_awsiface"
"github.com/loilo-inc/canarycage/test"
"github.com/loilo-inc/logos/di"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
"golang.org/x/xerrors"
)

Expand Down
2 changes: 1 addition & 1 deletion taskset/taskset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"testing"

ecstypes "github.com/aws/aws-sdk-go-v2/service/ecs/types"
"github.com/golang/mock/gomock"
"github.com/loilo-inc/canarycage/mocks/mock_task"
"github.com/loilo-inc/canarycage/task"
"github.com/loilo-inc/canarycage/taskset"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

func TestSet(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion test/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ import (
"github.com/aws/aws-sdk-go-v2/service/ecs"
ecstypes "github.com/aws/aws-sdk-go-v2/service/ecs/types"
elbv2 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
"github.com/golang/mock/gomock"
"github.com/loilo-inc/canarycage/env"
"github.com/loilo-inc/canarycage/mocks/mock_awsiface"
"go.uber.org/mock/gomock"
)

func Setup(ctrl *gomock.Controller, envars *env.Envars, currentTaskCount int, launchType ecstypes.LaunchType) (
Expand Down
2 changes: 1 addition & 1 deletion up_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"context"
"testing"

"github.com/golang/mock/gomock"
cage "github.com/loilo-inc/canarycage"
"github.com/loilo-inc/canarycage/key"
"github.com/loilo-inc/canarycage/test"
"github.com/loilo-inc/logos/di"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

func TestCage_Up(t *testing.T) {
Expand Down

0 comments on commit 51fc11a

Please sign in to comment.