Skip to content

Commit

Permalink
Merge pull request #396 from Gevrai/gejo-expecter-support
Browse files Browse the repository at this point in the history
Add mock generation with expecter
  • Loading branch information
LandonTClipp committed Jan 25, 2022
2 parents b702d89 + e5889c6 commit 66d6564
Show file tree
Hide file tree
Showing 8 changed files with 708 additions and 26 deletions.
1 change: 1 addition & 0 deletions cmd/mockery.go
Expand Up @@ -74,6 +74,7 @@ func NewRootCmd() *cobra.Command {
pFlags.String("boilerplate-file", "", "File to read a boilerplate text from. Text should be a go block comment, i.e. /* ... */")
pFlags.Bool("unroll-variadic", true, "For functions with variadic arguments, do not unroll the arguments into the underlying testify call. Instead, pass variadic slice as-is.")
pFlags.Bool("exported", false, "Generates public mocks for private interfaces.")
pFlags.Bool("with-expecter", false, "Generate expecter utility around mock's On, Run and Return methods with explicit types. This option is NOT compatible with -unroll-variadic=false")

viper.BindPFlags(pFlags)

Expand Down
6 changes: 6 additions & 0 deletions go.sum
Expand Up @@ -349,6 +349,12 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s=
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
github.com/vektra/mockery/v2 v2.9.0 h1:+3FhCL3EviR779mTzXwUuhPNnqFUA7sDnt9OFkXaFd4=
github.com/vektra/mockery/v2 v2.9.0/go.mod h1:2gU4Cf/f8YyC8oEaSXfCnZBMxMjMl/Ko205rlP0fO90=
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
1 change: 1 addition & 0 deletions pkg/config/config.go
Expand Up @@ -52,4 +52,5 @@ type Config struct {
TestOnly bool
UnrollVariadic bool `mapstructure:"unroll-variadic"`
Version bool
WithExpecter bool `mapstructure:"with-expecter"`
}
9 changes: 9 additions & 0 deletions pkg/fixtures/expecterTest.go
@@ -0,0 +1,9 @@
package test

type ExpecterTest interface {
NoArg() string
NoReturn(str string)
ManyArgsReturns(str string, i int) (strs []string, err error)
Variadic(ints ...int) error
VariadicMany(i int, a string, intfs ...interface{}) error
}
228 changes: 228 additions & 0 deletions pkg/fixtures/mocks/expecter.go

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

0 comments on commit 66d6564

Please sign in to comment.