diff --git a/go.mod b/go.mod index 326e0d7..2adef71 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,10 @@ module github.com/dir01/parcels go 1.21 +toolchain go1.22.2 require ( - github.com/gojuno/minimock/v3 v3.1.3 + github.com/gojuno/minimock/v3 v3.3.7 github.com/hori-ryota/zaperr v0.0.0-20210301022522-bfd0551d7f64 github.com/jmoiron/sqlx v1.3.5 github.com/mattn/go-sqlite3 v1.14.18 diff --git a/go.sum b/go.sum index f82e007..63f8fac 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bradleyjkemp/cupaloy v2.3.0+incompatible h1:UafIjBvWQmS9i/xRg+CamMrnLTKNzo+bdmT/oH34c2Y= -github.com/bradleyjkemp/cupaloy v2.3.0+incompatible/go.mod h1:Au1Xw1sgaJ5iSFktEhYsS0dbQiS1B0/XMXl+42y9Ilk= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= @@ -12,8 +10,8 @@ github.com/go-gorp/gorp/v3 v3.1.0 h1:ItKF/Vbuj31dmV4jxA1qblpSwkl9g1typ24xoe70IGs github.com/go-gorp/gorp/v3 v3.1.0/go.mod h1:dLEjIyyRNiXvNZ8PSmzpt1GsWAUK8kjVhEpjH8TixEw= github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE= github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= -github.com/gojuno/minimock/v3 v3.1.3 h1:9jakBeOqffZvR9BGBTulphLwiUfiju1w7JspU5eX/fY= -github.com/gojuno/minimock/v3 v3.1.3/go.mod h1:WylRuaQInND/eg0HqP0/6etOdtv67AIfOgPW1z8QtKU= +github.com/gojuno/minimock/v3 v3.3.7 h1:0hKsGb72PuXRIoBl/8lSte/jUHRXf1kVp+jEt7kcHhU= +github.com/gojuno/minimock/v3 v3.3.7/go.mod h1:vzti9ksNd88AUv2OeP9fDgsqb9xqh8iegLr/aiTOdt8= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= @@ -65,8 +63,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= diff --git a/vendor/github.com/gojuno/minimock/v3/.gitignore b/vendor/github.com/gojuno/minimock/v3/.gitignore index e7cf36a..3c0f7a1 100644 --- a/vendor/github.com/gojuno/minimock/v3/.gitignore +++ b/vendor/github.com/gojuno/minimock/v3/.gitignore @@ -29,3 +29,5 @@ _testmain.go /dist /bin /.gh_token + +.idea \ No newline at end of file diff --git a/vendor/github.com/gojuno/minimock/v3/.goreleaser.yml b/vendor/github.com/gojuno/minimock/v3/.goreleaser.yml index ea1ca7e..476513b 100644 --- a/vendor/github.com/gojuno/minimock/v3/.goreleaser.yml +++ b/vendor/github.com/gojuno/minimock/v3/.goreleaser.yml @@ -1,7 +1,4 @@ project_name: minimock -before: - hooks: - - make all builds: - main: ./cmd/minimock/ @@ -15,7 +12,7 @@ builds: - windows ldflags: - - -X main.version={{.Version}} -X main.commit={{.FullCommit}} -X main.buildDate={{.Date}} + - -X main.version={{.Tag}} -X main.commit={{.FullCommit}} -X main.buildDate={{.Date}} env_files: github_token: .gh_token diff --git a/vendor/github.com/gojuno/minimock/v3/.travis.yml b/vendor/github.com/gojuno/minimock/v3/.travis.yml deleted file mode 100644 index ae3b587..0000000 --- a/vendor/github.com/gojuno/minimock/v3/.travis.yml +++ /dev/null @@ -1,20 +0,0 @@ -language: go - -go: - - 1.x - -install: - - go get github.com/mattn/goveralls - - if ! go get github.com/golang/tools/cmd/cover; then go get golang.org/x/tools/cmd/cover; fi - - export BINDIR=./bin - - export PATH=`pwd`/bin:$PATH - - export GO111MODULE=on - -script: - - cd $TRAVIS_BUILD_DIR && make all - - cd tests/ - - go test -c -covermode=count -coverpkg=github.com/gojuno/minimock/tests - - ./tests.test -test.coverprofile coverage.cov - -after_script: - - $HOME/gopath/bin/goveralls -service=travis-ci -coverprofile=coverage.cov diff --git a/vendor/github.com/gojuno/minimock/v3/Makefile b/vendor/github.com/gojuno/minimock/v3/Makefile index c06cb95..f895037 100644 --- a/vendor/github.com/gojuno/minimock/v3/Makefile +++ b/vendor/github.com/gojuno/minimock/v3/Makefile @@ -7,13 +7,17 @@ all: install test lint generate: go run ./cmd/minimock/minimock.go -i github.com/gojuno/minimock/v3.Tester -o ./tests go run ./cmd/minimock/minimock.go -i ./tests.Formatter -o ./tests/formatter_mock.go - go run ./cmd/minimock/minimock.go -i ./tests.genericInout -o ./tests/generic/generic_inout.go - go run ./cmd/minimock/minimock.go -i ./tests.genericOut -o ./tests/generic/generic_out.go - go run ./cmd/minimock/minimock.go -i ./tests.genericIn -o ./tests/generic/generic_in.go - go run ./cmd/minimock/minimock.go -i ./tests.genericSpecific -o ./tests/generic/generic_specific.go - go run ./cmd/minimock/minimock.go -i ./tests.genericSimpleUnion -o ./tests/generic/generic_simple_union.go - go run ./cmd/minimock/minimock.go -i ./tests.genericComplexUnion -o ./tests/generic/generic_complex_union.go - go run ./cmd/minimock/minimock.go -i ./tests.genericInlineUnion -o ./tests/generic/generic_inline_union.go + go run ./cmd/minimock/minimock.go -i ./tests.genericInout -o ./tests/generic_inout.go + go run ./cmd/minimock/minimock.go -i ./tests.genericOut -o ./tests/generic_out.go + go run ./cmd/minimock/minimock.go -i ./tests.genericIn -o ./tests/generic_in.go + go run ./cmd/minimock/minimock.go -i ./tests.genericSpecific -o ./tests/generic_specific.go + go run ./cmd/minimock/minimock.go -i ./tests.genericSimpleUnion -o ./tests/generic_simple_union.go + go run ./cmd/minimock/minimock.go -i ./tests.genericComplexUnion -o ./tests/generic_complex_union.go + go run ./cmd/minimock/minimock.go -i ./tests.genericInlineUnion -o ./tests/generic_inline_union.go + go run ./cmd/minimock/minimock.go -i ./tests.genericInlineUnion -o ./tests/generic_inline_union.go + go run ./cmd/minimock/minimock.go -i ./tests.contextAccepter -o ./tests/context_accepter_mock.go + go run ./cmd/minimock/minimock.go -i github.com/gojuno/minimock/v3.Tester -o ./tests/package_name_specified_test.go -p tests_test + go run ./cmd/minimock/minimock.go -i ./tests.actor -o ./tests/actor_mock.go ./bin: mkdir ./bin @@ -26,7 +30,7 @@ install: go install ./cmd/minimock ./bin/golangci-lint: ./bin - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v1.51.1 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b ./bin v1.55.2 ./bin/goreleaser: ./bin go install -modfile tools/go.mod github.com/goreleaser/goreleaser @@ -34,11 +38,17 @@ install: ./bin/minimock: go build ./cmd/minimock -o ./bin/minimock +.PHONY: test: - go test $(go list ./... | grep -v /snapshots) + go test -race ./... -v release: ./bin/goreleaser - ./bin/goreleaser release + ./bin/goreleaser release --rm-dist build: ./bin/goreleaser ./bin/goreleaser build --snapshot --rm-dist + +.PHONY: +tidy: + go mod tidy + cd tools && go mod tidy diff --git a/vendor/github.com/gojuno/minimock/v3/README.md b/vendor/github.com/gojuno/minimock/v3/README.md index fa6f6b0..b0dab14 100644 --- a/vendor/github.com/gojuno/minimock/v3/README.md +++ b/vendor/github.com/gojuno/minimock/v3/README.md @@ -1,8 +1,6 @@ ![logo](https://rawgit.com/gojuno/minimock/master/logo.svg) [![GoDoc](https://godoc.org/github.com/gojuno/minimock?status.svg)](http://godoc.org/github.com/gojuno/minimock) -[![Build Status](https://travis-ci.org/gojuno/minimock.svg?branch=master)](https://travis-ci.org/gojuno/minimock) [![Go Report Card](https://goreportcard.com/badge/github.com/gojuno/minimock)](https://goreportcard.com/report/github.com/gojuno/minimock) -[![Coverage Status](https://coveralls.io/repos/github/gojuno/minimock/badge.svg?branch=master)](https://coveralls.io/github/gojuno/minimock?branch=master) [![Release](https://img.shields.io/github/release/gojuno/minimock.svg)](https://github.com/gojuno/minimock/releases/latest) [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/avelino/awesome-go#testing) @@ -20,7 +18,7 @@ The main features of minimock are: * It can generate several mocks in one run. * It generates code that passes [gometalinter](https://github.com/alecthomas/gometalinter) checks. * It puts //go:generate instruction into the generated code, so all you need to do when the source interface is updated is to run the `go generate ./...` command from within the project's directory. -* It provides Finish and Wait helpers to check if all mocked methods have been called during the test and keeps your test code clean and up to date. +* It makes sure that all mocked methods have been called during the test and keeps your test code clean and up to date. * It provides When and Then helpers to set up several expectations and results for any method. * It generates concurrent-safe mocks and mock invocation counters that you can use to manage mock behavior depending on the number of calls. * It can be used with the [GoUnit](https://github.com/hexdigest/gounit) tool which generates table-driven tests that make use of minimock. @@ -30,7 +28,7 @@ The main features of minimock are: If you use go modules please download the [latest binary](https://github.com/gojuno/minimock/releases/latest) or install minimock from source: ``` -go install github.com/gojuno/minimock/v3/cmd/minimock +go install github.com/gojuno/minimock/v3/cmd/minimock@latest ``` If you don't use go modules please find the latest v2.x binary [here](https://github.com/gojuno/minimock/releases) @@ -48,6 +46,9 @@ or install minimock using [v2 branch](https://github.com/gojuno/minimock/tree/v2 -o string comma-separated destination file names or packages to put the generated mocks in, by default the generated mock is placed in the source package directory + -p string + comma-separated package names, + by default the generated package names are taken from the destination directory names -s string mock file suffix (default "_mock_test.go") ``` @@ -126,8 +127,8 @@ readCloserMock := NewReadCloserMock(mc).ReadMock.Inspect(func(p []byte){ ```go mc := minimock.NewController(t) formatterMock := NewFormatterMock(mc) -formatterMock.When("Hello %s!", "world").Then("Hello world!") -formatterMock.When("Hi %s!", "there").Then("Hi there!") +formatterMock.FormatMock.When("Hello %s!", "world").Then("Hello world!") +formatterMock.FormatMock.When("Hi %s!", "there").Then("Hi there!") ``` alternatively you can use the one-liner: @@ -153,15 +154,38 @@ formatterMock.FormatMock.Set(func(string, ...interface{}) string { }) ``` +### Mocking context +Sometimes context gets modified by the time the mocked method is being called. +However, in most cases you don't really care about the exact value of the context argument. +In such cases you can use special `minimock.AnyContext` variable, here are a couple of examples: + +```go +mc := minimock.NewController(t) +senderMock := NewSenderMock(mc). + SendMock. + When(minimock.AnyContext, "message1").Then(nil). + When(minimock.AnyContext, "message2").Then(errors.New("invalid message")) +``` + +or using Expect: + +```go +mc := minimock.NewController(t) +senderMock := NewSenderMock(mc). + SendMock.Expect(minimock.AnyContext, "message").Return(nil) +``` + ### Make sure that your mocks are being used Often we write tons of mocks to test our code but sometimes the tested code stops using mocked dependencies. -You can easily identify this problem by using mc.Finish or mc.Wait helpers. +You can easily identify this problem by using `minimock.NewController` instead of just `*testing.T`. +Alternatively you can use `mc.Wait` helper if your're testing concurrent code. These helpers ensure that all your mocks and expectations have been used at least once during the test run. ```go func TestSomething(t *testing.T) { + // it will mark this example test as failed because there are no calls + // to formatterMock.Format() and readCloserMock.Read() below mc := minimock.NewController(t) - defer mc.Finish() //it will mark this example test as failed because there are no calls to formatterMock.Format() and readCloserMock.Read() below formatterMock := NewFormatterMock(mc) formatterMock.FormatMock.Return("minimock") diff --git a/vendor/github.com/gojuno/minimock/v3/equal.go b/vendor/github.com/gojuno/minimock/v3/equal.go index 2c43b4c..0e9010b 100644 --- a/vendor/github.com/gojuno/minimock/v3/equal.go +++ b/vendor/github.com/gojuno/minimock/v3/equal.go @@ -1,7 +1,9 @@ package minimock import ( + "context" "reflect" + "unsafe" "github.com/davecgh/go-spew/spew" "github.com/pmezard/go-difflib/difflib" @@ -13,12 +15,48 @@ var dumpConf = spew.ConfigState{ SortKeys: true, } +type anyContext struct { + context.Context +} + +var AnyContext = anyContext{} + // Equal returns true if a equals b func Equal(a, b interface{}) bool { if a == nil && b == nil { return a == b } + if reflect.TypeOf(a).Kind() == reflect.Struct { + aV := reflect.ValueOf(a) + bV := reflect.ValueOf(b) + + ap := reflect.New(aV.Type()).Elem() + bp := reflect.New(bV.Type()).Elem() + + ap.Set(aV) + bp.Set(bV) + + // for every field in a + for i := 0; i < reflect.TypeOf(a).NumField(); i++ { + aFieldValue := unexported(ap.Field(i)) + bFieldValue := unexported(bp.Field(i)) + + _, ok := aFieldValue.(anyContext) + if ok { + if ctx, ok := bFieldValue.(context.Context); ok && ctx != nil { + continue + } + } + + if !reflect.DeepEqual(aFieldValue, bFieldValue) { + return false + } + } + + return true + } + return reflect.DeepEqual(a, b) } @@ -61,3 +99,7 @@ func Diff(e, a interface{}) string { return "\n\nDiff:\n" + diff } + +func unexported(field reflect.Value) interface{} { + return reflect.NewAt(field.Type(), unsafe.Pointer(field.UnsafeAddr())).Elem().Interface() +} diff --git a/vendor/github.com/gojuno/minimock/v3/mock_controller.go b/vendor/github.com/gojuno/minimock/v3/mock_controller.go index e432a25..60d8d4d 100644 --- a/vendor/github.com/gojuno/minimock/v3/mock_controller.go +++ b/vendor/github.com/gojuno/minimock/v3/mock_controller.go @@ -5,7 +5,7 @@ import ( "time" ) -//Mocker describes common interface for all mocks generated by minimock +// Mocker describes common interface for all mocks generated by minimock type Mocker interface { MinimockFinish() MinimockWait(time.Duration) @@ -18,19 +18,20 @@ type Tester interface { Error(...interface{}) Errorf(format string, args ...interface{}) FailNow() + Cleanup(f func()) } -//MockController can be passed to mocks generated by minimock +// MockController can be passed to mocks generated by minimock type MockController interface { Tester RegisterMocker(Mocker) } -//Controller implements MockController interface and has to be used in your tests: -//mockController := minimock.NewController(t) -//defer mockController.Finish() -//stringerMock := NewStringerMock(mockController) +// Controller implements MockController interface and has to be used in your tests: +// mockController := minimock.NewController(t) +// defer mockController.Finish() +// stringerMock := NewStringerMock(mockController) type Controller struct { Tester sync.Mutex @@ -41,19 +42,26 @@ type Controller struct { // Check if Controller supports MockController interface var _ MockController = &Controller{} -//NewController returns an instance of Controller +// NewController returns an instance of Controller func NewController(t Tester) *Controller { - return &Controller{Tester: newSafeTester(t)} + c := Controller{Tester: newSafeTester(t)} + t.Cleanup(c.Finish) + + return &c } -//RegisterMocker puts mocker to the list of controller mockers +// RegisterMocker puts mocker to the list of controller mockers func (c *Controller) RegisterMocker(m Mocker) { c.Lock() c.mockers = append(c.mockers, m) c.Unlock() } -//Finish calls to MinimockFinish method for all registered mockers +// Finish calls to MinimockFinish method for all registered mockers +// +// Deprecated: Finish exists for historical compatibility +// and should not be used. Current implementation of controller registers +// Finish as Cleanup function for the testing.T instance passed to NewController. func (c *Controller) Finish() { c.Lock() for _, m := range c.mockers { @@ -62,7 +70,7 @@ func (c *Controller) Finish() { c.Unlock() } -//Wait calls to MinimockWait method for all registered mockers +// Wait calls to MinimockWait method for all registered mockers func (c *Controller) Wait(d time.Duration) { wg := sync.WaitGroup{} wg.Add(len(c.mockers)) diff --git a/vendor/github.com/gojuno/minimock/v3/template.go b/vendor/github.com/gojuno/minimock/v3/template.go index 5b5a244..7fc8173 100644 --- a/vendor/github.com/gojuno/minimock/v3/template.go +++ b/vendor/github.com/gojuno/minimock/v3/template.go @@ -3,12 +3,17 @@ package minimock const ( // HeaderTemplate is used to generate package clause and go:generate instruction HeaderTemplate = ` - package {{$.Package.Name}} + {{ $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.OutputFile}} -n {{(title (index $.Vars "MockName"))}} + //go:generate minimock -i {{$.SourcePackage.PkgPath}}.{{$.Options.InterfaceName}} -o {{$.Options.HeaderVars.OutputFile}} -n {{(title (index $.Vars "MockName"))}} -p {{ $packageName }} {{end}} import ( @@ -28,6 +33,8 @@ const ( // {{$mock}} implements {{$.Interface.Type}} type {{$mock}}{{(params)}} struct { t minimock.Tester + finishOnce sync.Once + {{ range $method := $.Interface.Methods }} func{{$method.Name}} func{{ $method.Signature }} inspectFunc{{$method.Name}} func({{ $method.Params}}) @@ -40,6 +47,7 @@ const ( // New{{$mock}} returns a mock for {{$.Interface.Type}} func New{{$mock}}{{(params)}}(t minimock.Tester) *{{$mock}}{{(paramsRef)}} { m := &{{$mock}}{{(paramsRef)}}{t: t} + if controller, ok := t.(minimock.MockController); ok { controller.RegisterMocker(m) } @@ -47,6 +55,9 @@ const ( m.{{$method.Name}}Mock = m{{$mock}}{{$method.Name}}{{(paramsRef)}}{mock: m} {{ if $method.HasParams }} m.{{$method.Name}}Mock.callArgs = []*{{$mock}}{{$method.Name}}Params{{(paramsRef)}}{} {{ end }} {{ end }} + + t.Cleanup(m.MinimockFinish) + return m } @@ -67,6 +78,7 @@ const ( type {{$mock}}{{$method.Name}}Expectation{{(params)}} struct { mock *{{$mock}}{{(paramsRef)}} {{ if $method.HasParams }} params *{{$mock}}{{$method.Name}}Params{{(paramsRef)}} {{end}} + {{ if $method.HasParams }} paramPtrs *{{$mock}}{{$method.Name}}ParamPtrs{{(paramsRef)}} {{end}} {{ if $method.HasResults }} results *{{$mock}}{{$method.Name}}Results{{(paramsRef)}} {{end}} Counter uint64 } @@ -76,6 +88,11 @@ const ( type {{$mock}}{{$method.Name}}Params{{(params)}} {{$method.ParamsStruct}} {{end}} + {{if $method.HasParams }} + // {{$mock}}{{$method.Name}}ParamPtrs contains pointers to parameters of the {{$.Interface.Name}}.{{$method.Name}} + type {{$mock}}{{$method.Name}}ParamPtrs{{(params)}} {{$method.ParamPtrsStruct}} + {{end}} + {{if $method.HasResults }} // {{$mock}}{{$method.Name}}Results contains results of the {{$.Interface.Name}}.{{$method.Name}} type {{$mock}}{{$method.Name}}Results{{(params)}} {{$method.ResultsStruct}} @@ -92,6 +109,10 @@ const ( } {{if $method.HasParams }} + if {{$m}}.defaultExpectation.paramPtrs != nil { + {{$m}}.mock.t.Fatalf("{{$mock}}.{{$method.Name}} mock is already set by ExpectParams functions") + } + {{$m}}.defaultExpectation.params = &{{$mock}}{{$method.Name}}Params{{(paramsRef)}}{ {{ $method.ParamsNames }} } for _, e := range {{$m}}.expectations { if minimock.Equal(e.params, {{$m}}.defaultExpectation.params) { @@ -102,6 +123,29 @@ const ( return {{$m}} } + {{ range $idx, $param := $method.Params }} + // Expect{{ $param.Name | title }}Param{{$idx | inc}} sets up expected param {{ $param.Name }} for {{$.Interface.Name}}.{{$method.Name}} + func ({{$m}} *m{{$mock}}{{$method.Name}}{{(paramsRef)}}) Expect{{ $param.Name | title }}Param{{$idx | inc}}({{$param.Name}} {{$param.Type}}) *m{{$mock}}{{$method.Name}}{{(paramsRef)}} { + if {{$m}}.mock.func{{$method.Name}} != nil { + {{$m}}.mock.t.Fatalf("{{$mock}}.{{$method.Name}} mock is already set by Set") + } + + if {{$m}}.defaultExpectation == nil { + {{$m}}.defaultExpectation = &{{$mock}}{{$method.Name}}Expectation{{(paramsRef)}}{} + } + + if {{$m}}.defaultExpectation.params != nil { + {{$m}}.mock.t.Fatalf("{{$mock}}.{{$method.Name}} mock is already set by Expect") + } + + if {{$m}}.defaultExpectation.paramPtrs == nil { + {{$m}}.defaultExpectation.paramPtrs = &{{$mock}}{{$method.Name}}ParamPtrs{{(paramsRef)}}{} + } + {{$m}}.defaultExpectation.paramPtrs.{{$param.Name}} = &{{$param.Name}} + + return {{$m}} + } + {{ end }} // Inspect accepts an inspector function that has same arguments as the {{$.Interface.Name}}.{{$method.Name}} func ({{$m}} *m{{$mock}}{{$method.Name}}{{(paramsRef)}}) Inspect(f func({{$method.Params}})) *m{{$mock}}{{$method.Name}}{{(paramsRef)}} { if {{$m}}.mock.inspectFunc{{$method.Name}} != nil { @@ -173,15 +217,15 @@ const ( } {{if $method.HasParams}} - mm_params := &{{$mock}}{{$method.Name}}Params{{(paramsRef)}}{ {{$method.ParamsNames}} } + mm_params := {{$mock}}{{$method.Name}}Params{{(paramsRef)}}{ {{$method.ParamsNames}} } // Record call args {{$m}}.{{$method.Name}}Mock.mutex.Lock() - {{$m}}.{{$method.Name}}Mock.callArgs = append({{$m}}.{{$method.Name}}Mock.callArgs, mm_params) + {{$m}}.{{$method.Name}}Mock.callArgs = append({{$m}}.{{$method.Name}}Mock.callArgs, &mm_params) {{$m}}.{{$method.Name}}Mock.mutex.Unlock() for _, e := range {{$m}}.{{$method.Name}}Mock.expectations { - if minimock.Equal(e.params, mm_params) { + if minimock.Equal(*e.params, mm_params) { mm_atomic.AddUint64(&e.Counter, 1) {{$method.ReturnStruct "e.results" -}} } @@ -192,8 +236,17 @@ const ( mm_atomic.AddUint64(&{{$m}}.{{$method.Name}}Mock.defaultExpectation.Counter, 1) {{- if $method.HasParams }} mm_want := {{$m}}.{{$method.Name}}Mock.defaultExpectation.params + mm_want_ptrs := {{$m}}.{{$method.Name}}Mock.defaultExpectation.paramPtrs + mm_got := {{$mock}}{{$method.Name}}Params{{(paramsRef)}}{ {{$method.ParamsNames}} } - if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { + + if mm_want_ptrs != nil { + {{ range $idx, $param := $method.Params }} + if mm_want_ptrs.{{$param.Name}} != nil && !minimock.Equal(*mm_want_ptrs.{{$param.Name}}, mm_got.{{$param.Name}}) { + {{$m}}.t.Errorf("{{$mock}}.{{$method.Name}} got unexpected parameter {{$param.Name}}, want: %#v, got: %#v%s\n", *mm_want_ptrs.{{$param.Name}}, mm_got.{{$param.Name}}, minimock.Diff(*mm_want_ptrs.{{$param.Name}}, mm_got.{{$param.Name}})) + } + {{ end }} + } else if mm_want != nil && !minimock.Equal(*mm_want, mm_got) { {{$m}}.t.Errorf("{{$mock}}.{{$method.Name}} got unexpected parameters, want: %#v, got: %#v%s\n", *mm_want, mm_got, minimock.Diff(*mm_want, mm_got)) } {{ end }} @@ -292,12 +345,14 @@ const ( // MinimockFinish checks that all mocked methods have been called the expected number of times func (m *{{$mock}}{{(paramsRef)}}) MinimockFinish() { - if !m.minimockDone() { - {{- range $method := $.Interface.Methods }} - m.Minimock{{$method.Name}}Inspect() - {{ end -}} - m.t.FailNow() - } + m.finishOnce.Do(func() { + if !m.minimockDone() { + {{- range $method := $.Interface.Methods }} + m.Minimock{{$method.Name}}Inspect() + {{ end -}} + m.t.FailNow() + } + }) } // MinimockWait waits for all mocked methods to be called the expected number of times diff --git a/vendor/github.com/rubenv/sql-migrate/test-migrations/1_initial.sql b/vendor/github.com/rubenv/sql-migrate/test-migrations/1_initial.sql deleted file mode 100644 index cd896fb..0000000 --- a/vendor/github.com/rubenv/sql-migrate/test-migrations/1_initial.sql +++ /dev/null @@ -1,8 +0,0 @@ --- +migrate Up --- SQL in section 'Up' is executed when this migration is applied -CREATE TABLE people (id int); - - --- +migrate Down --- SQL section 'Down' is executed when this migration is rolled back -DROP TABLE people; diff --git a/vendor/github.com/rubenv/sql-migrate/test-migrations/2_record.sql b/vendor/github.com/rubenv/sql-migrate/test-migrations/2_record.sql deleted file mode 100644 index c76d769..0000000 --- a/vendor/github.com/rubenv/sql-migrate/test-migrations/2_record.sql +++ /dev/null @@ -1,5 +0,0 @@ --- +migrate Up -INSERT INTO people (id) VALUES (1); - --- +migrate Down -DELETE FROM people WHERE id=1; diff --git a/vendor/modules.txt b/vendor/modules.txt index 5b96e79..4145505 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -10,8 +10,8 @@ github.com/davecgh/go-spew/spew # github.com/go-gorp/gorp/v3 v3.1.0 ## explicit; go 1.18 github.com/go-gorp/gorp/v3 -# github.com/gojuno/minimock/v3 v3.1.3 -## explicit; go 1.18 +# github.com/gojuno/minimock/v3 v3.3.7 +## explicit; go 1.22 github.com/gojuno/minimock/v3 # github.com/hori-ryota/zaperr v0.0.0-20210301022522-bfd0551d7f64 ## explicit; go 1.16