Skip to content

Commit

Permalink
Merge pull request #118 from zcolleen/master
Browse files Browse the repository at this point in the history
Bump gowrap + links on expectation lines feauture
  • Loading branch information
hexdigest authored Aug 31, 2024
2 parents 2d9fb52 + ac85d34 commit c3b5c46
Show file tree
Hide file tree
Showing 31 changed files with 1,985 additions and 951 deletions.
13 changes: 13 additions & 0 deletions caller.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package minimock

import (
"fmt"
"runtime"
)

func CallerInfo(skip int) string {
if _, file, line, ok := runtime.Caller(skip + 1); ok {
return fmt.Sprintf("%s:%d", file, line)
}
return "unknown file"
}
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@ module github.com/gojuno/minimock/v3

require (
github.com/davecgh/go-spew v1.1.1
github.com/hexdigest/gowrap v1.3.10
github.com/hexdigest/gowrap v1.4.0
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.0
github.com/stretchr/testify v1.8.4
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a
golang.org/x/tools v0.1.12
google.golang.org/protobuf v1.30.0
)

require (
github.com/kr/text v0.2.0 // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/sys v0.5.0 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f // indirect
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
17 changes: 9 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ3
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/hexdigest/gowrap v1.3.10 h1:e8NwAdtnwpRJ4Ks76+GctDNCFIkHR2TCFCWshug/zIE=
github.com/hexdigest/gowrap v1.3.10/go.mod h1:5KTYxPjK1RRfD+9L4Oo9gjP3XNAs4rkoVK2E7eAEFyM=
github.com/hexdigest/gowrap v1.4.0 h1:Zjhnl1omZXJs40S1K0gaWQjvO9ADy3u1sGqLkYJNcP8=
github.com/hexdigest/gowrap v1.4.0/go.mod h1:uOPX6MbEZnYtf5i5/+rS0Aj8NC3P/V594uaoaiMMbRg=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
Expand All @@ -22,12 +21,14 @@ github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XF
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o=
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a h1:ofrrl6c6NG5/IOSx/R1cyiQxxjqlur0h/TvbUhkH0II=
golang.org/x/tools v0.1.11-0.20220316014157-77aa08bb151a/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f h1:GGU+dLjvlC3qDwqYgL6UgRmHXhOOgns0bZu2Ty5mm6U=
golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
Expand Down
407 changes: 407 additions & 0 deletions internal/templates/body.tmpl

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions internal/templates/header.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{{ $packageName := $.Package.Name }}
{{if $.Options.HeaderVars.PackageName }}
{{ $packageName = $.Options.HeaderVars.PackageName }}
{{end}}

// Code generated by http://github.com/gojuno/minimock ({{$.Options.HeaderVars.Version}}). DO NOT EDIT.

package {{$packageName}}

{{if $.Options.HeaderVars.GenerateInstruction}}
//go:generate minimock -i {{$.SourcePackage.PkgPath}}.{{$.Options.InterfaceName}} -o {{$.Options.HeaderVars.OutputFile}} -n {{(title (index $.Vars "MockName"))}} -p {{ $packageName }}
{{end}}

import (
{{range $import := $.Options.Imports}}{{- if not (in $import "\"time\"" "\"sync/atomic\"" "\"github.com/gojuno/minimock/v3\"")}}
{{$import}}{{end}}{{end}}
mm_atomic "sync/atomic"
mm_time "time"
"github.com/gojuno/minimock/v3"
)
1 change: 1 addition & 0 deletions mock_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type Tester interface {
Errorf(format string, args ...interface{})
FailNow()
Cleanup(f func())
Helper()
}

// MockController can be passed to mocks generated by minimock
Expand Down
4 changes: 4 additions & 0 deletions mock_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,7 @@ type unsafeTester struct {
func (u *unsafeTester) Fatal(...interface{}) {
u.finished = true
}

func (u *unsafeTester) Helper() {

}
4 changes: 4 additions & 0 deletions safe_tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ func newSafeTester(t Tester) *safeTester {
func (st *safeTester) Error(args ...interface{}) {
st.m.Lock()
defer st.m.Unlock()
st.Tester.Helper()

st.Tester.Error(args...)
}
Expand All @@ -23,6 +24,7 @@ func (st *safeTester) Error(args ...interface{}) {
func (st *safeTester) Errorf(format string, args ...interface{}) {
st.m.Lock()
defer st.m.Unlock()
st.Tester.Helper()

st.Tester.Errorf(format, args...)
}
Expand All @@ -31,6 +33,7 @@ func (st *safeTester) Errorf(format string, args ...interface{}) {
func (st *safeTester) Fatal(args ...interface{}) {
st.m.Lock()
defer st.m.Unlock()
st.Tester.Helper()

st.Tester.Fatal(args...)
}
Expand All @@ -39,6 +42,7 @@ func (st *safeTester) Fatal(args ...interface{}) {
func (st *safeTester) Fatalf(format string, args ...interface{}) {
st.m.Lock()
defer st.m.Unlock()
st.Tester.Helper()

st.Tester.Fatalf(format, args...)
}
Loading

0 comments on commit c3b5c46

Please sign in to comment.