Skip to content

Commit c3b5c46

Browse files
authored
Merge pull request #118 from zcolleen/master
Bump gowrap + links on expectation lines feauture
2 parents 2d9fb52 + ac85d34 commit c3b5c46

31 files changed

+1985
-951
lines changed

caller.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package minimock
2+
3+
import (
4+
"fmt"
5+
"runtime"
6+
)
7+
8+
func CallerInfo(skip int) string {
9+
if _, file, line, ok := runtime.Caller(skip + 1); ok {
10+
return fmt.Sprintf("%s:%d", file, line)
11+
}
12+
return "unknown file"
13+
}

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,19 @@ module github.com/gojuno/minimock/v3
22

33
require (
44
github.com/davecgh/go-spew v1.1.1
5-
github.com/hexdigest/gowrap v1.3.10
5+
github.com/hexdigest/gowrap v1.4.0
66
github.com/pkg/errors v0.9.1
77
github.com/pmezard/go-difflib v1.0.0
88
github.com/stretchr/testify v1.8.4
9-
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a
9+
golang.org/x/tools v0.1.12
1010
google.golang.org/protobuf v1.30.0
1111
)
1212

1313
require (
1414
github.com/kr/text v0.2.0 // indirect
15-
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
15+
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
1616
golang.org/x/sys v0.5.0 // indirect
17+
golang.org/x/text v0.3.7 // indirect
1718
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
1819
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
1920
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
22
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
33
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
44
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
5+
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
56
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
6-
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
7-
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
8-
github.com/hexdigest/gowrap v1.3.10 h1:e8NwAdtnwpRJ4Ks76+GctDNCFIkHR2TCFCWshug/zIE=
9-
github.com/hexdigest/gowrap v1.3.10/go.mod h1:5KTYxPjK1RRfD+9L4Oo9gjP3XNAs4rkoVK2E7eAEFyM=
7+
github.com/hexdigest/gowrap v1.4.0 h1:Zjhnl1omZXJs40S1K0gaWQjvO9ADy3u1sGqLkYJNcP8=
8+
github.com/hexdigest/gowrap v1.4.0/go.mod h1:uOPX6MbEZnYtf5i5/+rS0Aj8NC3P/V594uaoaiMMbRg=
109
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
1110
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
1211
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
@@ -22,12 +21,14 @@ github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XF
2221
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
2322
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
2423
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
25-
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
26-
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
24+
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
25+
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
2726
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
2827
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
29-
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a h1:ofrrl6c6NG5/IOSx/R1cyiQxxjqlur0h/TvbUhkH0II=
30-
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
28+
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
29+
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
30+
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
31+
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
3132
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
3233
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f h1:GGU+dLjvlC3qDwqYgL6UgRmHXhOOgns0bZu2Ty5mm6U=
3334
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

internal/templates/body.tmpl

Lines changed: 407 additions & 0 deletions
Large diffs are not rendered by default.

internal/templates/header.tmpl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{{ $packageName := $.Package.Name }}
2+
{{if $.Options.HeaderVars.PackageName }}
3+
{{ $packageName = $.Options.HeaderVars.PackageName }}
4+
{{end}}
5+
6+
// Code generated by http://github.com/gojuno/minimock ({{$.Options.HeaderVars.Version}}). DO NOT EDIT.
7+
8+
package {{$packageName}}
9+
10+
{{if $.Options.HeaderVars.GenerateInstruction}}
11+
//go:generate minimock -i {{$.SourcePackage.PkgPath}}.{{$.Options.InterfaceName}} -o {{$.Options.HeaderVars.OutputFile}} -n {{(title (index $.Vars "MockName"))}} -p {{ $packageName }}
12+
{{end}}
13+
14+
import (
15+
{{range $import := $.Options.Imports}}{{- if not (in $import "\"time\"" "\"sync/atomic\"" "\"github.com/gojuno/minimock/v3\"")}}
16+
{{$import}}{{end}}{{end}}
17+
mm_atomic "sync/atomic"
18+
mm_time "time"
19+
"github.com/gojuno/minimock/v3"
20+
)

mock_controller.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ type Tester interface {
1919
Errorf(format string, args ...interface{})
2020
FailNow()
2121
Cleanup(f func())
22+
Helper()
2223
}
2324

2425
// MockController can be passed to mocks generated by minimock

mock_controller_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,7 @@ type unsafeTester struct {
8585
func (u *unsafeTester) Fatal(...interface{}) {
8686
u.finished = true
8787
}
88+
89+
func (u *unsafeTester) Helper() {
90+
91+
}

safe_tester.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ func newSafeTester(t Tester) *safeTester {
1515
func (st *safeTester) Error(args ...interface{}) {
1616
st.m.Lock()
1717
defer st.m.Unlock()
18+
st.Tester.Helper()
1819

1920
st.Tester.Error(args...)
2021
}
@@ -23,6 +24,7 @@ func (st *safeTester) Error(args ...interface{}) {
2324
func (st *safeTester) Errorf(format string, args ...interface{}) {
2425
st.m.Lock()
2526
defer st.m.Unlock()
27+
st.Tester.Helper()
2628

2729
st.Tester.Errorf(format, args...)
2830
}
@@ -31,6 +33,7 @@ func (st *safeTester) Errorf(format string, args ...interface{}) {
3133
func (st *safeTester) Fatal(args ...interface{}) {
3234
st.m.Lock()
3335
defer st.m.Unlock()
36+
st.Tester.Helper()
3437

3538
st.Tester.Fatal(args...)
3639
}
@@ -39,6 +42,7 @@ func (st *safeTester) Fatal(args ...interface{}) {
3942
func (st *safeTester) Fatalf(format string, args ...interface{}) {
4043
st.m.Lock()
4144
defer st.m.Unlock()
45+
st.Tester.Helper()
4246

4347
st.Tester.Fatalf(format, args...)
4448
}

0 commit comments

Comments
 (0)