Skip to content

Commit

Permalink
add mockery to go generate (cadence-workflow#4887)
Browse files Browse the repository at this point in the history
  • Loading branch information
shijiesheng authored Jul 5, 2022
1 parent 6f9e2d9 commit cfd637e
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 39 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ LINT_SRC := $(filter-out %_test.go ./.gen/%, $(ALL_SRC))
# downloads and builds a go-gettable tool, versioned by go.mod, and installs
# it into the build folder, named the same as the last portion of the URL.
define go_build_tool
@echo "building $(notdir $(1)) from $(1)..."
@go build -mod=readonly -o $(BIN)/$(notdir $(1)) $(1)
@echo "building $(or $(2), $(notdir $(1))) from $(1)..."
@go build -mod=readonly -o $(BIN)/$(or $(2), $(notdir $(1))) $(1)
endef

# utility target.
Expand All @@ -128,6 +128,9 @@ $(BIN)/thriftrw-plugin-yarpc: go.mod
$(BIN)/mockgen: go.mod
$(call go_build_tool,github.com/golang/mock/mockgen)

$(BIN)/mockery: go.mod
$(call go_build_tool,github.com/vektra/mockery/v2,mockery)

$(BIN)/enumer: go.mod
$(call go_build_tool,github.com/dmarkham/enumer)

Expand Down Expand Up @@ -397,7 +400,7 @@ cadence-bench: $(BUILD)/lint
bins: $(BINS)
tools: $(TOOLS)

go-generate: $(BIN)/mockgen $(BIN)/enumer
go-generate: $(BIN)/mockgen $(BIN)/enumer $(BIN)/mockery
@echo "running go generate ./..., this takes almost 5 minutes..."
@# add our bins to PATH so `go generate` can find them
@$(BIN_PATH) go generate ./...
Expand Down
2 changes: 2 additions & 0 deletions cmd/server/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import (
_ "golang.org/x/tools/cmd/goimports"
// mockgen for generating mocks
_ "github.com/golang/mock/mockgen"
// mockery for generating mocks
_ "github.com/vektra/mockery/v2"
// enumer for generating utility methods for const enums
_ "github.com/dmarkham/enumer"
// replaces golint - configurable and much faster
Expand Down
8 changes: 4 additions & 4 deletions common/archiver/s3store/mocks/S3API.go

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

25 changes: 25 additions & 0 deletions common/archiver/s3store/mocks/S3API_mock.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// The MIT License (MIT)

// Copyright (c) 2017-2020 Uber Technologies Inc.

// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.

package mocks

//go:generate mockery --srcpkg github.com/aws/aws-sdk-go/service/s3/s3iface --quiet --name S3API --output .
46 changes: 31 additions & 15 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/dgryski/go-farm v0.0.0-20200201041132-a6ae2369ad13
github.com/dmarkham/enumer v1.5.1
github.com/emirpasic/gods v0.0.0-20190624094223-e689965507ab
github.com/fatih/color v1.10.0
github.com/fatih/color v1.13.0
github.com/go-sql-driver/mysql v1.5.0
github.com/gocql/gocql v0.0.0-20211015133455-b225f9b53fa1
github.com/gogo/protobuf v1.3.2
Expand All @@ -36,15 +36,16 @@ require (
github.com/otiai10/copy v1.1.1
github.com/pborman/uuid v0.0.0-20180906182336-adf5a7427709
github.com/robfig/cron v1.2.0
github.com/sirupsen/logrus v1.4.2
github.com/stretchr/testify v1.6.1
github.com/sirupsen/logrus v1.6.0
github.com/stretchr/testify v1.7.2
github.com/uber-go/tally v3.3.15+incompatible
github.com/uber/cadence-idl v0.0.0-20220624003202-b8700886ba45
github.com/uber/ringpop-go v0.8.5
github.com/uber/tchannel-go v1.22.0
github.com/uber/tcheck v1.1.0
github.com/urfave/cli v1.22.4
github.com/valyala/fastjson v1.4.1
github.com/vektra/mockery/v2 v2.0.3
github.com/xdg/scram v0.0.0-20180814205039-7eeb5667e42c
github.com/xwb1989/sqlparser v0.0.0-20180606152119-120387863bf2
go.mongodb.org/mongo-driver v1.7.3
Expand All @@ -56,11 +57,11 @@ require (
go.uber.org/thriftrw v1.29.2
go.uber.org/yarpc v1.58.0
go.uber.org/zap v1.13.0
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/time v0.0.0-20191024005414-555d28b269f0
golang.org/x/tools v0.1.5
golang.org/x/tools v0.1.11
gonum.org/v1/gonum v0.7.0
google.golang.org/api v0.26.0
google.golang.org/grpc v1.29.1
Expand All @@ -78,12 +79,13 @@ require (
github.com/benbjohnson/clock v0.0.0-20161215174838-7dc76406b6d3 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0 // indirect
github.com/eapache/go-resiliency v1.2.0 // indirect
github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21 // indirect
github.com/eapache/queue v1.1.0 // indirect
github.com/facebookgo/clock v0.0.0-20150410010913-600d898af40a // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/fsnotify/fsnotify v1.4.7 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gogo/googleapis v1.3.2 // indirect
github.com/gogo/status v1.1.0 // indirect
Expand All @@ -94,26 +96,31 @@ require (
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/hashicorp/go-uuid v1.0.1 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/jcmturner/gofork v1.0.0 // indirect
github.com/jessevdk/go-flags v1.4.0 // indirect
github.com/jmespath/go-jmespath v0.3.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/jstemmer/go-junit-report v0.9.1 // indirect
github.com/kisielk/errcheck v1.5.0 // indirect
github.com/klauspost/compress v1.13.6 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/m3db/prometheus_client_model v0.1.0 // indirect
github.com/m3db/prometheus_common v0.1.0 // indirect
github.com/m3db/prometheus_procfs v0.8.1 // indirect
github.com/magiconair/properties v1.8.1 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.7 // indirect
github.com/mattn/go-sqlite3 v1.11.0 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mgechev/dots v0.0.0-20190921121421-c36f7dcfbb81 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.1.2 // indirect
github.com/pascaldekloe/name v1.0.0 // indirect
github.com/pelletier/go-toml v1.7.0 // indirect
github.com/pierrec/lz4 v0.0.0-20190701081048-057d66e894a4 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
Expand All @@ -122,9 +129,17 @@ require (
github.com/prometheus/common v0.9.1 // indirect
github.com/prometheus/procfs v0.0.9 // indirect
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a // indirect
github.com/rs/zerolog v1.18.0 // indirect
github.com/russross/blackfriday/v2 v2.0.1 // indirect
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
github.com/spf13/afero v1.1.2 // indirect
github.com/spf13/cast v1.3.0 // indirect
github.com/spf13/cobra v1.0.0 // indirect
github.com/spf13/jwalterweatherman v1.0.0 // indirect
github.com/spf13/pflag v1.0.3 // indirect
github.com/spf13/viper v1.7.0 // indirect
github.com/stretchr/objx v0.2.0 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/uber-common/bark v1.2.1 // indirect
github.com/uber-go/mapdecode v1.0.0 // indirect
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
Expand All @@ -135,23 +150,24 @@ require (
go.opencensus.io v0.22.5 // indirect
go.uber.org/dig v1.10.0 // indirect
go.uber.org/net/metrics v1.3.0 // indirect
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 // indirect
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6 // indirect
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/sys v0.0.0-20211004093028-2c5d950f24ef // indirect
golang.org/x/text v0.3.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e // indirect
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.51.0 // indirect
gopkg.in/jcmturner/aescts.v1 v1.0.1 // indirect
gopkg.in/jcmturner/dnsutils.v1 v1.0.1 // indirect
gopkg.in/jcmturner/goidentity.v3 v3.0.0 // indirect
gopkg.in/jcmturner/gokrb5.v7 v7.3.0 // indirect
gopkg.in/jcmturner/rpc.v1 v1.1.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
honnef.co/go/tools v0.0.1-2020.1.4 // indirect
)

Expand Down
Loading

0 comments on commit cfd637e

Please sign in to comment.