Skip to content

Commit

Permalink
chore(mocks): fully migrate mockery to gomock (#3031)
Browse files Browse the repository at this point in the history
- Replace all generated mockery by mockgen generated mocks
- Replace all usages of mockery mocks with new mockgen mocks
- Fix mock usages (sometimes with `.AnyTimes()`)
- Replace all `mock.Anything` and `mock.AnyAssignableTo` by `gomock.Any()`
- Remove mockery from CI
- Remove mockery from documentation
- Use local `ECSAPI` interface for devnet for a (much) smaller generated mock (-4000 lines)
  • Loading branch information
qdm12 committed Jan 13, 2023
1 parent a116d58 commit 6255f39
Show file tree
Hide file tree
Showing 72 changed files with 2,844 additions and 7,331 deletions.
2 changes: 0 additions & 2 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ For coding style, you may refer to the [code style](CODE_STYLE.md) document whic
Generate the mock code with `go generate -run "mockgen" ./...` from your working directory. This will also update existing mocks. You can update all mocks by running `go generate -run "mockgen" ./...` from the repository root. Note this does not log anything out.
⚠️ We are still using `mockery` instead of `gomock` for older mocks, so you need to run `go generate -run "mockery|mockgen" ./...` to update all the existing mocks. We are slowly migrating our mocks and test code to use `gomock`.
> To execute `//go:generate` commands that are placed at files with `//go:build integration` remember to add `-tags integration` in the `go generate` command eg. `go generate -tags integration ...`
9. **Lint your changes.**
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/mocks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,18 @@ jobs:
stable: true
check-latest: true

- run: go install github.com/vektra/mockery/v2@v2.14

- run: go install github.com/golang/mock/mockgen@v1.6

- name: Check devnet module
run: |
cd devnet && \
go mod download && \
go generate -run "mockery" -tags integration ./... && \
go generate -run "mockgen" -tags integration ./... && \
git diff --exit-code && \
cd ..
- name: Check Gossamer module
run: |
go mod download && \
go generate -run "mockery" -tags integration ./... && \
go generate -run "mockgen" -tags integration ./... && \
git diff --exit-code
20 changes: 20 additions & 0 deletions devnet/cmd/scale-down-ecs-service/internal/interfaces.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright 2023 ChainSafe Systems (ON)
// SPDX-License-Identifier: LGPL-3.0-only

package internal

import (
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/request"
"github.com/aws/aws-sdk-go/service/ecs"
)

// ECSAPI is the interface for the ECS API.
type ECSAPI interface {
ListServicesWithContext(aws.Context, *ecs.ListServicesInput, ...request.Option) (
*ecs.ListServicesOutput, error)
UpdateServiceWithContext(aws.Context, *ecs.UpdateServiceInput, ...request.Option) (
*ecs.UpdateServiceOutput, error)
DescribeServicesWithContext(aws.Context, *ecs.DescribeServicesInput, ...request.Option) (
*ecs.DescribeServicesOutput, error)
}
Loading

0 comments on commit 6255f39

Please sign in to comment.