Skip to content

Commit a70796d

Browse files
author
Gevrai Jodoin-Tremblay
committed
Add mock generation with expecter
1 parent 95d9e1c commit a70796d

File tree

8 files changed

+709
-29
lines changed

8 files changed

+709
-29
lines changed

cmd/mockery.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ func init() {
9393
pFlags.String("boilerplate-file", "", "File to read a boilerplate text from. Text should be a go block comment, i.e. /* ... */")
9494
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.")
9595
pFlags.Bool("exported", false, "Generates public mocks for private interfaces.")
96+
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")
9697

9798
viper.BindPFlags(pFlags)
9899
}

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,8 @@ github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s
193193
github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw=
194194
github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
195195
github.com/ugorji/go v1.1.4/go.mod h1:uQMGLiO92mf5W77hV/PUCpI3pbzQx3CRekS0kk+RGrc=
196+
github.com/vektra/mockery/v2 v2.9.0 h1:+3FhCL3EviR779mTzXwUuhPNnqFUA7sDnt9OFkXaFd4=
197+
github.com/vektra/mockery/v2 v2.9.0/go.mod h1:2gU4Cf/f8YyC8oEaSXfCnZBMxMjMl/Ko205rlP0fO90=
196198
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
197199
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
198200
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=

pkg/config/config.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package config
44
var SemVer = "v0.0.0-dev"
55

66
func GetSemverInfo() string {
7-
return SemVer
7+
return SemVer
88
}
99

1010
type Config struct {
@@ -39,4 +39,5 @@ type Config struct {
3939
TestOnly bool
4040
UnrollVariadic bool `mapstructure:"unroll-variadic"`
4141
Version bool
42+
WithExpecter bool `mapstructure:"with-expecter"`
4243
}

pkg/fixtures/expecterTest.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package test
2+
3+
type ExpecterTest interface {
4+
NoArg() string
5+
NoReturn(str string)
6+
ManyArgsReturns(str string, i int) (strs []string, err error)
7+
Variadic(ints ...int) error
8+
VariadicMany(i int, a string, intfs ...interface{}) error
9+
}

pkg/fixtures/mocks/expecter.go

Lines changed: 228 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)