├── .gitignore ├── mocktail.png ├── mocktail-dark.png ├── testdata ├── src │ ├── a │ │ ├── c │ │ │ └── c.go │ │ ├── d │ │ │ └── d.go │ │ ├── b │ │ │ └── b.go │ │ ├── e │ │ │ └── v2 │ │ │ │ └── e.go │ │ ├── go.mod │ │ ├── a.go │ │ ├── mock_test.go │ │ └── go.sum │ └── b │ │ ├── b.go │ │ ├── go.mod │ │ ├── c │ │ ├── mock_test.go │ │ └── c.go │ │ └── go.sum └── exported │ ├── a │ ├── c │ │ └── c.go │ ├── b │ │ └── b.go │ ├── go.mod │ ├── a.go │ ├── mock_test.go │ └── go.sum │ └── b │ ├── b.go │ ├── go.mod │ ├── c │ ├── c.go │ ├── mock_test.go │ └── mock_gen.go │ └── go.sum ├── Makefile ├── go.mod ├── .github └── workflows │ ├── go-cross.yml │ ├── release.yml │ └── ci.yml ├── mod.go ├── .goreleaser.yml ├── go.sum ├── .golangci.yml ├── readme.md ├── mocktail_test.go ├── mocktail.go ├── LICENSE └── syrup.go /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | mocktail 3 | dist/ 4 | -------------------------------------------------------------------------------- /mocktail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/traefik/mocktail/HEAD/mocktail.png -------------------------------------------------------------------------------- /mocktail-dark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/traefik/mocktail/HEAD/mocktail-dark.png -------------------------------------------------------------------------------- /testdata/src/a/c/c.go: -------------------------------------------------------------------------------- 1 | package c 2 | 3 | type Cherry struct { 4 | Name string 5 | } 6 | -------------------------------------------------------------------------------- /testdata/exported/a/c/c.go: -------------------------------------------------------------------------------- 1 | package c 2 | 3 | type Cherry struct { 4 | Name string 5 | } 6 | -------------------------------------------------------------------------------- /testdata/src/b/b.go: -------------------------------------------------------------------------------- 1 | package b 2 | 3 | func Hello() string { 4 | return "hello" 5 | } 6 | -------------------------------------------------------------------------------- /testdata/exported/b/b.go: -------------------------------------------------------------------------------- 1 | package b 2 | 3 | func Hello() string { 4 | return "hello" 5 | } 6 | -------------------------------------------------------------------------------- /testdata/src/a/d/d.go: -------------------------------------------------------------------------------- 1 | package c 2 | 3 | import ( 4 | "a/e/v2" 5 | ) 6 | 7 | type Cherry interface { 8 | V2Carrot() e.V2Carrot 9 | } 10 | -------------------------------------------------------------------------------- /testdata/src/a/b/b.go: -------------------------------------------------------------------------------- 1 | package b 2 | 3 | import ( 4 | "a/c" 5 | ) 6 | 7 | type Carrot interface { 8 | Bar(string) *Potato 9 | Bur(string) *c.Cherry 10 | } 11 | 12 | type Potato struct { 13 | Name string 14 | } 15 | -------------------------------------------------------------------------------- /testdata/exported/a/b/b.go: -------------------------------------------------------------------------------- 1 | package b 2 | 3 | import ( 4 | "a/c" 5 | ) 6 | 7 | type Carrot interface { 8 | Bar(string) *Potato 9 | Bur(string) *c.Cherry 10 | } 11 | 12 | type Potato struct { 13 | Name string 14 | } 15 | -------------------------------------------------------------------------------- /testdata/src/a/e/v2/e.go: -------------------------------------------------------------------------------- 1 | package e 2 | 3 | import ( 4 | "a/c" 5 | ) 6 | 7 | type V2Carrot interface { 8 | Bar(string) *V2Potato 9 | Bur(string) *c.Cherry 10 | } 11 | 12 | type V2Potato struct { 13 | Name string 14 | } 15 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: clean lint test build 2 | 3 | default: clean lint test build 4 | 5 | lint: 6 | golangci-lint run 7 | 8 | clean: 9 | rm -rf cover.out 10 | 11 | test: clean 12 | go test -v -cover ./... 13 | 14 | build: clean 15 | CGO_ENABLED=0 go build -trimpath -ldflags '-w -s' 16 | -------------------------------------------------------------------------------- /testdata/src/a/go.mod: -------------------------------------------------------------------------------- 1 | module a 2 | 3 | go 1.18 4 | 5 | require ( 6 | github.com/stretchr/testify v1.8.0 7 | golang.org/x/mod v0.5.1 8 | ) 9 | 10 | require ( 11 | github.com/davecgh/go-spew v1.1.1 // indirect 12 | github.com/pmezard/go-difflib v1.0.0 // indirect 13 | github.com/stretchr/objx v0.4.0 // indirect 14 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect 15 | gopkg.in/yaml.v3 v3.0.1 // indirect 16 | ) 17 | -------------------------------------------------------------------------------- /testdata/src/b/go.mod: -------------------------------------------------------------------------------- 1 | module b 2 | 3 | go 1.18 4 | 5 | require ( 6 | github.com/stretchr/testify v1.8.0 7 | golang.org/x/mod v0.5.1 8 | ) 9 | 10 | require ( 11 | github.com/davecgh/go-spew v1.1.1 // indirect 12 | github.com/pmezard/go-difflib v1.0.0 // indirect 13 | github.com/stretchr/objx v0.4.0 // indirect 14 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect 15 | gopkg.in/yaml.v3 v3.0.1 // indirect 16 | ) 17 | -------------------------------------------------------------------------------- /testdata/exported/a/go.mod: -------------------------------------------------------------------------------- 1 | module a 2 | 3 | go 1.18 4 | 5 | require ( 6 | github.com/stretchr/testify v1.8.0 7 | golang.org/x/mod v0.5.1 8 | ) 9 | 10 | require ( 11 | github.com/davecgh/go-spew v1.1.1 // indirect 12 | github.com/pmezard/go-difflib v1.0.0 // indirect 13 | github.com/stretchr/objx v0.4.0 // indirect 14 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect 15 | gopkg.in/yaml.v3 v3.0.1 // indirect 16 | ) 17 | -------------------------------------------------------------------------------- /testdata/exported/b/go.mod: -------------------------------------------------------------------------------- 1 | module b 2 | 3 | go 1.18 4 | 5 | require ( 6 | github.com/stretchr/testify v1.8.0 7 | golang.org/x/mod v0.5.1 8 | ) 9 | 10 | require ( 11 | github.com/davecgh/go-spew v1.1.1 // indirect 12 | github.com/pmezard/go-difflib v1.0.0 // indirect 13 | github.com/stretchr/objx v0.4.0 // indirect 14 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 // indirect 15 | gopkg.in/yaml.v3 v3.0.1 // indirect 16 | ) 17 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/traefik/mocktail 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | github.com/ettle/strcase v0.2.0 7 | github.com/stretchr/testify v1.9.0 8 | golang.org/x/tools v0.32.0 9 | ) 10 | 11 | require ( 12 | github.com/davecgh/go-spew v1.1.1 // indirect 13 | github.com/pmezard/go-difflib v1.0.0 // indirect 14 | golang.org/x/mod v0.24.0 // indirect 15 | golang.org/x/sync v0.13.0 // indirect 16 | gopkg.in/yaml.v3 v3.0.1 // indirect 17 | ) 18 | -------------------------------------------------------------------------------- /testdata/src/b/c/mock_test.go: -------------------------------------------------------------------------------- 1 | package c 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | ) 7 | 8 | // mocktail:Pineapple 9 | // mocktail:Coconut 10 | 11 | func TestName(t *testing.T) { 12 | var s Pineapple = newPineappleMock(t). 13 | OnHello(Water{}).TypedReturns("a").Once(). 14 | OnWorld().TypedReturns("a").Once(). 15 | OnGoo().TypedReturns("", 1, Water{}).Once(). 16 | OnCoo("", Water{}).TypedReturns(Water{}). 17 | TypedRun(func(s string, water Water) {}).Once(). 18 | Parent 19 | 20 | s.Hello(Water{}) 21 | s.World() 22 | s.Goo() 23 | s.Coo(context.Background(), "", Water{}) 24 | 25 | fn := func(st Strawberry, stban Strawberry) Pineapple { 26 | return s 27 | } 28 | 29 | var c Coconut = newCoconutMock(t). 30 | OnLoo("a", 1, 2).TypedReturns("foo").Once(). 31 | OnMoo(fn).TypedReturns("").Once(). 32 | Parent 33 | 34 | c.Loo("a", 1, 2) 35 | c.Moo(fn) 36 | } 37 | -------------------------------------------------------------------------------- /testdata/src/b/c/c.go: -------------------------------------------------------------------------------- 1 | package c 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "time" 7 | 8 | "golang.org/x/mod/module" 9 | ) 10 | 11 | type Pineapple interface { 12 | Hello(bar Water) string 13 | World() string 14 | Goo() (string, int, Water) 15 | Coo(context.Context, string, Water) Water 16 | } 17 | 18 | type Coconut interface { 19 | Boo(src *bytes.Buffer) time.Duration 20 | Doo(src time.Duration) time.Duration 21 | Foo(st Strawberry) string 22 | Goo(st string) Strawberry 23 | Hoo(string, int, Water) 24 | Joo(string, int, Water) (string, int) 25 | Koo(src string) (dst string) 26 | Loo(st string, values ...int) string 27 | Too(src string) time.Duration 28 | Voo(src *module.Version) time.Duration 29 | Yoo(st string) interface{} 30 | Zoo(st interface{}) string 31 | Moo(fn func(st, stban Strawberry) Pineapple) string 32 | } 33 | 34 | type Water struct{} 35 | 36 | type Strawberry interface { 37 | Bar(string) int 38 | } 39 | -------------------------------------------------------------------------------- /testdata/exported/b/c/c.go: -------------------------------------------------------------------------------- 1 | package c 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "time" 7 | 8 | "golang.org/x/mod/module" 9 | ) 10 | 11 | type Pineapple interface { 12 | Hello(bar Water) string 13 | World() string 14 | Goo() (string, int, Water) 15 | Coo(context.Context, string, Water) Water 16 | } 17 | 18 | type Coconut interface { 19 | Boo(src *bytes.Buffer) time.Duration 20 | Doo(src time.Duration) time.Duration 21 | Foo(st Strawberry) string 22 | Goo(st string) Strawberry 23 | Hoo(string, int, Water) 24 | Joo(string, int, Water) (string, int) 25 | Koo(src string) (dst string) 26 | Loo(st string, values ...int) string 27 | Too(src string) time.Duration 28 | Voo(src *module.Version) time.Duration 29 | Yoo(st string) interface{} 30 | Zoo(st interface{}) string 31 | Moo(fn func(st, stban Strawberry) Pineapple) string 32 | } 33 | 34 | type Water struct{} 35 | 36 | type Strawberry interface { 37 | Bar(string) int 38 | } 39 | -------------------------------------------------------------------------------- /.github/workflows/go-cross.yml: -------------------------------------------------------------------------------- 1 | name: Go Matrix 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | jobs: 10 | 11 | cross: 12 | name: Go 13 | runs-on: ${{ matrix.os }} 14 | env: 15 | CGO_ENABLED: 0 16 | 17 | strategy: 18 | matrix: 19 | go-version: [ stable, oldstable ] 20 | os: [ubuntu-latest, macos-latest, windows-latest] 21 | 22 | steps: 23 | # https://github.com/marketplace/actions/checkout 24 | - name: Checkout code 25 | uses: actions/checkout@v4 26 | 27 | # https://github.com/marketplace/actions/setup-go-environment 28 | - name: Set up Go ${{ matrix.go-version }} 29 | uses: actions/setup-go@v5 30 | with: 31 | go-version: ${{ matrix.go-version }} 32 | 33 | - name: Test 34 | run: go test -v -cover ./... 35 | 36 | - name: Build 37 | run: go build -v -ldflags "-s -w" -trimpath 38 | -------------------------------------------------------------------------------- /testdata/exported/b/c/mock_test.go: -------------------------------------------------------------------------------- 1 | package c_test 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | 7 | "b/c" 8 | ) 9 | 10 | // mocktail:Pineapple 11 | // mocktail:Coconut 12 | 13 | func TestName(t *testing.T) { 14 | var s c.Pineapple = c.NewPineappleMock(t). 15 | OnHello(c.Water{}).TypedReturns("a").Once(). 16 | OnWorld().TypedReturns("a").Once(). 17 | OnGoo().TypedReturns("", 1, c.Water{}).Once(). 18 | OnCoo("", c.Water{}).TypedReturns(c.Water{}). 19 | TypedRun(func(s string, water c.Water) {}).Once(). 20 | Parent 21 | 22 | s.Hello(c.Water{}) 23 | s.World() 24 | s.Goo() 25 | s.Coo(context.Background(), "", c.Water{}) 26 | 27 | fn := func(st c.Strawberry, stban c.Strawberry) c.Pineapple { 28 | return s 29 | } 30 | 31 | var coco c.Coconut = c.NewCoconutMock(t). 32 | OnLoo("a", 1, 2).TypedReturns("foo").Once(). 33 | OnMoo(fn).TypedReturns("").Once(). 34 | Parent 35 | 36 | coco.Loo("a", 1, 2) 37 | coco.Moo(fn) 38 | } 39 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: "Release a tag" 2 | on: 3 | push: 4 | tags: 5 | - v* 6 | 7 | jobs: 8 | release: 9 | name: Release Process 10 | runs-on: ubuntu-latest 11 | env: 12 | GO_VERSION: stable 13 | CGO_ENABLED: 0 14 | 15 | steps: 16 | # https://github.com/marketplace/actions/checkout 17 | - name: Check out code 18 | uses: actions/checkout@v4 19 | with: 20 | fetch-depth: 0 21 | 22 | # https://github.com/marketplace/actions/setup-go-environment 23 | - name: Set up Go ${{ env.GO_VERSION }} 24 | uses: actions/setup-go@v5 25 | with: 26 | go-version: ${{ env.GO_VERSION }} 27 | 28 | # https://goreleaser.com/ci/actions/ 29 | - name: Run GoReleaser 30 | uses: goreleaser/goreleaser-action@v6 31 | with: 32 | version: latest 33 | args: release --clean 34 | env: 35 | GITHUB_TOKEN: ${{ secrets.GH_TOKEN_REPO }} 36 | -------------------------------------------------------------------------------- /testdata/exported/a/a.go: -------------------------------------------------------------------------------- 1 | package a 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "time" 7 | 8 | "golang.org/x/mod/module" 9 | ) 10 | 11 | type Pineapple interface { 12 | Hello(bar Water) string 13 | World() string 14 | Goo() (string, int, Water) 15 | Coo(context.Context, string, Water) Water 16 | Noo(context.Context) string 17 | } 18 | 19 | type Coconut interface { 20 | Boo(src *bytes.Buffer) time.Duration 21 | Doo(src time.Duration) time.Duration 22 | Foo(st Strawberry) string 23 | Goo(st string) Strawberry 24 | Hoo(string, int, Water) 25 | Joo(string, int, Water) (string, int) 26 | Koo(src string) (dst string) 27 | Loo(st string, values ...int) string 28 | Too(src string) time.Duration 29 | Voo(src *module.Version) time.Duration 30 | Yoo(st string) interface{} 31 | Zoo(st interface{}) string 32 | Moo(fn func(st, stban Strawberry) Pineapple) string 33 | } 34 | 35 | type Water struct{} 36 | 37 | type Strawberry interface { 38 | Bar(string) int 39 | } 40 | 41 | type Orange interface { 42 | Juice() <-chan struct{} 43 | } 44 | -------------------------------------------------------------------------------- /testdata/src/a/a.go: -------------------------------------------------------------------------------- 1 | package a 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "time" 7 | 8 | "golang.org/x/mod/module" 9 | ) 10 | 11 | type Pineapple interface { 12 | Hello(bar Water) string 13 | World() string 14 | Goo() (string, int, Water) 15 | Coo(context.Context, string, Water) Water 16 | Noo(context.Context) string 17 | } 18 | 19 | type Coconut interface { 20 | Boo(src *bytes.Buffer) time.Duration 21 | Doo(src time.Duration) time.Duration 22 | Foo(st Strawberry) string 23 | Goo(st string) Strawberry 24 | Hoo(string, int, Water) 25 | Joo(string, int, Water) (string, int) 26 | Koo(src string) (dst string) 27 | Loo(st string, values ...int) string 28 | Too(src string) time.Duration 29 | Voo(src *module.Version) time.Duration 30 | Yoo(st string) interface{} 31 | Zoo(st interface{}) string 32 | Moo(fn func(st, stban Strawberry) Pineapple) string 33 | Noo(ar [][2]string) string 34 | Poo(str struct{ name string }) string 35 | } 36 | 37 | type Water struct{} 38 | 39 | type Strawberry interface { 40 | Bar(string) int 41 | } 42 | 43 | type Orange interface { 44 | Juice() <-chan struct{} 45 | } 46 | -------------------------------------------------------------------------------- /mod.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "bytes" 5 | "encoding/json" 6 | "errors" 7 | "fmt" 8 | "os/exec" 9 | ) 10 | 11 | type modInfo struct { 12 | Path string `json:"Path"` // module name 13 | Dir string `json:"Dir"` // absolute path to the module 14 | GoMod string `json:"GoMod"` // absolute path to the go.mod 15 | GoVersion string `json:"GoVersion"` 16 | Main bool `json:"Main"` 17 | } 18 | 19 | func getModuleInfo(dir string) (modInfo, error) { 20 | // https://github.com/golang/go/issues/44753#issuecomment-790089020 21 | cmd := exec.Command("go", "list", "-m", "-json") 22 | if dir != "" { 23 | cmd.Dir = dir 24 | } 25 | 26 | raw, err := cmd.CombinedOutput() 27 | if err != nil { 28 | return modInfo{}, fmt.Errorf("command go list: %w: %s", err, string(raw)) 29 | } 30 | 31 | var v modInfo 32 | err = json.NewDecoder(bytes.NewBuffer(raw)).Decode(&v) 33 | if err != nil { 34 | return modInfo{}, fmt.Errorf("unmarshaling error: %w: %s", err, string(raw)) 35 | } 36 | 37 | if v.GoMod == "" { 38 | return modInfo{}, errors.New("working directory is not part of a module") 39 | } 40 | 41 | return v, nil 42 | } 43 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: Main 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | pull_request: 8 | 9 | jobs: 10 | 11 | main: 12 | name: Main Process 13 | runs-on: ubuntu-latest 14 | env: 15 | GO_VERSION: stable 16 | GOLANGCI_LINT_VERSION: v1.62.0 17 | CGO_ENABLED: 0 18 | 19 | steps: 20 | # https://github.com/marketplace/actions/checkout 21 | - name: Check out code 22 | uses: actions/checkout@v4 23 | 24 | # https://github.com/marketplace/actions/setup-go-environment 25 | - name: Set up Go ${{ env.GO_VERSION }} 26 | uses: actions/setup-go@v5 27 | with: 28 | go-version: ${{ env.GO_VERSION }} 29 | - name: Check and get dependencies 30 | run: | 31 | go mod download 32 | go mod tidy 33 | git diff --exit-code go.mod 34 | git diff --exit-code go.sum 35 | 36 | # https://golangci-lint.run/usage/install#other-ci 37 | - name: Install golangci-lint ${{ env.GOLANGCI_LINT_VERSION }} 38 | run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} 39 | 40 | - name: Make 41 | run: make 42 | -------------------------------------------------------------------------------- /testdata/exported/a/mock_test.go: -------------------------------------------------------------------------------- 1 | package a_test 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | "time" 7 | 8 | "a" 9 | ) 10 | 11 | // mocktail:Pineapple 12 | // mocktail:Coconut 13 | // mocktail:b.Carrot 14 | // mocktail-:fmt.Stringer 15 | // mocktail:Orange 16 | 17 | func TestName(t *testing.T) { 18 | var s a.Pineapple = a.NewPineappleMock(t). 19 | OnHello(a.Water{}).TypedReturns("a").Once(). 20 | OnWorld().TypedReturns("a").Once(). 21 | OnGoo().TypedReturns("", 1, a.Water{}).Once(). 22 | OnCoo("", a.Water{}).TypedReturns(a.Water{}). 23 | TypedRun(func(s string, water a.Water) {}).Once(). 24 | Parent 25 | 26 | s.Hello(a.Water{}) 27 | s.World() 28 | s.Goo() 29 | s.Coo(context.Background(), "", a.Water{}) 30 | 31 | fn := func(st a.Strawberry, stban a.Strawberry) a.Pineapple { 32 | return s 33 | } 34 | 35 | var c a.Coconut = a.NewCoconutMock(t). 36 | OnLoo("a", 1, 2).TypedReturns("foo").Once(). 37 | OnMoo(fn).TypedReturns("").Once(). 38 | Parent 39 | 40 | c.Loo("a", 1, 2) 41 | c.Moo(fn) 42 | 43 | juiceCh := make(chan struct{}, 1) 44 | juiceCh <- struct{}{} 45 | 46 | var o a.Orange = a.NewOrangeMock(t). 47 | OnJuice().TypedReturns(juiceCh).Once(). 48 | Parent 49 | 50 | select { 51 | case <-o.Juice(): 52 | case <-time.After(10 * time.Millisecond): 53 | t.Fatalf("timed out waiting for an orange juice") 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /.goreleaser.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | project_name: mocktail 3 | 4 | builds: 5 | - binary: mocktail 6 | goos: 7 | - windows 8 | - darwin 9 | - linux 10 | - freebsd 11 | - openbsd 12 | goarch: 13 | - amd64 14 | - 386 15 | - arm 16 | - arm64 17 | goarm: 18 | - 7 19 | 20 | ignore: 21 | - goos: darwin 22 | goarch: 386 23 | - goos: openbsd 24 | goarch: arm 25 | 26 | changelog: 27 | sort: asc 28 | filters: 29 | exclude: 30 | - '^docs:' 31 | - '^doc:' 32 | - '^chore:' 33 | - '^chore(deps):' 34 | - '^test:' 35 | - '^tests:' 36 | 37 | archives: 38 | - id: mocktail 39 | name_template: '{{ .ProjectName }}_v{{ .Version }}_{{ .Os }}_{{ .Arch }}{{ if .Arm}}v{{ .Arm }}{{ end }}' 40 | format: tar.gz 41 | format_overrides: 42 | - goos: windows 43 | format: zip 44 | files: 45 | - LICENSE 46 | 47 | brews: 48 | - repository: 49 | owner: traefik 50 | name: homebrew-tap 51 | commit_author: 52 | name: traefiker 53 | email: 30906710+traefiker@users.noreply.github.com 54 | directory: Formula 55 | homepage: https://github.com/traefik/mocktail 56 | description: | 57 | Naive code generator that creates mock implementation using testify.mock. 58 | test: | 59 | system "echo 0" 60 | 61 | -------------------------------------------------------------------------------- /testdata/src/a/mock_test.go: -------------------------------------------------------------------------------- 1 | package a 2 | 3 | import ( 4 | "context" 5 | "testing" 6 | "time" 7 | ) 8 | 9 | // mocktail:Pineapple 10 | // mocktail:Coconut 11 | // mocktail:b.Carrot 12 | // mocktail-:fmt.Stringer 13 | // mocktail:Orange 14 | // mocktail:d.Cherry 15 | 16 | func TestName(t *testing.T) { 17 | var s Pineapple = newPineappleMock(t). 18 | OnHello(Water{}).TypedReturns("a").Once(). 19 | OnWorld().TypedReturns("a").Once(). 20 | OnGoo().TypedReturns("", 1, Water{}).Once(). 21 | OnCoo("", Water{}).TypedReturns(Water{}). 22 | TypedRun(func(s string, water Water) {}).Once(). 23 | Parent 24 | 25 | s.Hello(Water{}) 26 | s.World() 27 | s.Goo() 28 | s.Coo(context.Background(), "", Water{}) 29 | 30 | fn := func(st Strawberry, stban Strawberry) Pineapple { 31 | return s 32 | } 33 | 34 | var c Coconut = newCoconutMock(t). 35 | OnLoo("a", 1, 2).TypedReturns("foo").Once(). 36 | OnMoo(fn).TypedReturns("").Once(). 37 | OnNoo([][2]string{{"a", "b"}}).TypedReturns(""). 38 | OnPoo(struct{ name string }{name: "poo"}).TypedReturns("").Once(). 39 | Parent 40 | 41 | c.Loo("a", 1, 2) 42 | c.Moo(fn) 43 | c.Noo([][2]string{{"a", "b"}}) 44 | c.Poo(struct{ name string }{name: "poo"}) 45 | 46 | juiceCh := make(chan struct{}, 1) 47 | juiceCh <- struct{}{} 48 | 49 | var o Orange = newOrangeMock(t). 50 | OnJuice().TypedReturns(juiceCh).Once(). 51 | Parent 52 | 53 | select { 54 | case <-o.Juice(): 55 | case <-time.After(10 * time.Millisecond): 56 | t.Fatalf("timed out waiting for an orange juice") 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 2 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 3 | github.com/ettle/strcase v0.2.0 h1:fGNiVF21fHXpX1niBgk0aROov1LagYsOwV/xqKDKR/Q= 4 | github.com/ettle/strcase v0.2.0/go.mod h1:DajmHElDSaX76ITe3/VHVyMin4LWSJN5Z909Wp+ED1A= 5 | github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= 6 | github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 7 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 8 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 9 | github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= 10 | github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= 11 | golang.org/x/mod v0.24.0 h1:ZfthKaKaT4NrhGVZHO1/WDTwGES4De8KtWO0SIbNJMU= 12 | golang.org/x/mod v0.24.0/go.mod h1:IXM97Txy2VM4PJ3gI61r1YEk/gAj6zAHN3AdZt6S9Ww= 13 | golang.org/x/sync v0.13.0 h1:AauUjRAJ9OSnvULf/ARrrVywoJDy0YS2AwQ98I37610= 14 | golang.org/x/sync v0.13.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA= 15 | golang.org/x/tools v0.32.0 h1:Q7N1vhpkQv7ybVzLFtTjvQya2ewbwNDZzUgfXGqtMWU= 16 | golang.org/x/tools v0.32.0/go.mod h1:ZxrU41P/wAbZD8EDa6dDCa6XfpkhJ7HFMjHJXfBDu8s= 17 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 18 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 19 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 20 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 21 | -------------------------------------------------------------------------------- /testdata/src/a/go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 2 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 3 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 5 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 6 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 7 | github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= 8 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 9 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 10 | github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= 11 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 12 | golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= 13 | golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= 14 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= 15 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 16 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 17 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 18 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 19 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 20 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 21 | -------------------------------------------------------------------------------- /testdata/src/b/go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 2 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 3 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 5 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 6 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 7 | github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= 8 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 9 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 10 | github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= 11 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 12 | golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= 13 | golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= 14 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= 15 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 16 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 17 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 18 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 19 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 20 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 21 | -------------------------------------------------------------------------------- /testdata/exported/a/go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 2 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 3 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 5 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 6 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 7 | github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= 8 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 9 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 10 | github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= 11 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 12 | golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= 13 | golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= 14 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= 15 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 16 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 17 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 18 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 19 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 20 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 21 | -------------------------------------------------------------------------------- /testdata/exported/b/go.sum: -------------------------------------------------------------------------------- 1 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 2 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 3 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 4 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 5 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 6 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 7 | github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= 8 | github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= 9 | github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 10 | github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= 11 | github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= 12 | golang.org/x/mod v0.5.1 h1:OJxoQ/rynoF0dcCdI7cLPktw/hR2cueqYfjm43oqK38= 13 | golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= 14 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898 h1:/atklqdjdhuosWIl6AIbOeHJjicWYPqR9bpxqxYG2pA= 15 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 16 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 17 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 18 | gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 19 | gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= 20 | gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 21 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | run: 2 | timeout: 10m 3 | 4 | linters-settings: 5 | govet: 6 | enable-all: true 7 | disable: 8 | - fieldalignment 9 | gocyclo: 10 | min-complexity: 15 11 | goconst: 12 | min-len: 5 13 | min-occurrences: 3 14 | misspell: 15 | locale: US 16 | funlen: 17 | lines: -1 18 | statements: 50 19 | godox: 20 | keywords: 21 | - FIXME 22 | gofumpt: 23 | extra-rules: true 24 | depguard: 25 | rules: 26 | main: 27 | deny: 28 | - pkg: "github.com/instana/testify" 29 | desc: not allowed 30 | - pkg: "github.com/pkg/errors" 31 | desc: Should be replaced by standard lib errors package 32 | gocritic: 33 | enabled-tags: 34 | - diagnostic 35 | - style 36 | - performance 37 | disabled-checks: 38 | - sloppyReassign 39 | - rangeValCopy 40 | - octalLiteral 41 | - paramTypeCombine # already handle by gofumpt.extra-rules 42 | - unnamedResult 43 | - hugeParam 44 | tagliatelle: 45 | case: 46 | rules: 47 | json: pascal 48 | gosec: 49 | excludes: 50 | - G304 51 | - G306 52 | 53 | linters: 54 | enable-all: true 55 | disable: 56 | - exportloopref # deprecated 57 | - sqlclosecheck # not relevant (SQL) 58 | - rowserrcheck # not relevant (SQL) 59 | - cyclop # duplicate of gocyclo 60 | - lll 61 | - dupl 62 | - wsl 63 | - nlreturn 64 | - mnd 65 | - err113 66 | - wrapcheck 67 | - exhaustive 68 | - exhaustruct 69 | - testpackage 70 | - tparallel 71 | - paralleltest 72 | - prealloc 73 | - forcetypeassert 74 | - bodyclose # Too many false positives: https://github.com/timakin/bodyclose/issues/30 75 | - varnamelen 76 | - nilnil 77 | - ireturn 78 | - errchkjson 79 | - contextcheck 80 | 81 | issues: 82 | exclude-use-default: false 83 | max-issues-per-linter: 0 84 | max-same-issues: 0 85 | exclude: 86 | - 'fmt.Sprintf can be replaced with string' 87 | exclude-rules: 88 | - path: .*_test.go 89 | linters: 90 | - funlen 91 | - noctx 92 | 93 | output: 94 | show-stats: true 95 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Mocktail 2 | 3 |

4 | 5 | 6 | 7 | Mocktail logo 8 | 9 |

10 | 11 | Naive code generator that creates mock implementation using `testify.mock`. 12 | 13 | Unlike [mockery](https://github.com/vektra/mockery), Mocktail generates typed methods on mocks. 14 | 15 | For an explanation of why we created Mocktail, you can read [this article](https://traefik.io/blog/mocktail-the-mock-generator-for-strongly-typed-mocks/). 16 | 17 | ## How to use 18 | 19 | - Create a file named `mock_test.go` inside the package that you can to create mocks. 20 | - Add one or multiple comments `// mocktail:MyInterface` inside the file `mock_test.go`. 21 | 22 | ```go 23 | package example 24 | 25 | // mocktail:MyInterface 26 | 27 | ``` 28 | 29 | ## How to Install 30 | 31 | ### Go Install 32 | 33 | You can install Mocktail by running the following command: 34 | 35 | ```bash 36 | go install github.com/traefik/mocktail@latest 37 | ``` 38 | 39 | ### Pre-build Binaries 40 | 41 | You can use pre-compiled binaries: 42 | 43 | * To get the binary just download the latest release for your OS/Arch from [the releases page](https://github.com/traefik/mocktail/releases) 44 | * Unzip the archive. 45 | * Add `mocktail` in your `PATH`. 46 | 47 | ## Notes 48 | 49 | It requires testify >= v1.7.0 50 | 51 | Mocktail can only generate mock of interfaces inside a module itself (not from stdlib or dependencies) 52 | 53 | The `// mocktail` comments **must** be added to a file named `mock_test.go` only, 54 | comments in other files will not be detected 55 | 56 | ## Examples 57 | 58 | ```go 59 | package a 60 | 61 | import ( 62 | "context" 63 | "time" 64 | ) 65 | 66 | type Pineapple interface { 67 | Juice(context.Context, string, Water) Water 68 | } 69 | 70 | type Coconut interface { 71 | Open(string, int) time.Duration 72 | } 73 | 74 | type Water struct{} 75 | ``` 76 | 77 | ```go 78 | package a 79 | 80 | import ( 81 | "context" 82 | "testing" 83 | ) 84 | 85 | // mocktail:Pineapple 86 | // mocktail:Coconut 87 | 88 | func TestMock(t *testing.T) { 89 | var s Pineapple = newPineappleMock(t). 90 | OnJuice("foo", Water{}).TypedReturns(Water{}).Once(). 91 | Parent 92 | 93 | s.Juice(context.Background(), "", Water{}) 94 | 95 | var c Coconut = newCoconutMock(t). 96 | OnOpen("bar", 2).Once(). 97 | Parent 98 | 99 | c.Open("a", 2) 100 | } 101 | ``` 102 | 103 | ## Exportable Mocks 104 | 105 | If you need to use your mocks in external packages just add flag `-e`: 106 | 107 | ```shell 108 | mocktail -e 109 | ``` 110 | 111 | In this case, mock will be created in the same package but in the file `mock_gen.go`. 112 | 113 | 123 | -------------------------------------------------------------------------------- /mocktail_test.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "io/fs" 5 | "os" 6 | "os/exec" 7 | "path/filepath" 8 | "runtime" 9 | "testing" 10 | 11 | "github.com/stretchr/testify/assert" 12 | "github.com/stretchr/testify/require" 13 | ) 14 | 15 | func TestMocktail(t *testing.T) { 16 | const testRoot = "./testdata/src" 17 | 18 | if runtime.GOOS == "windows" { 19 | t.Skip(runtime.GOOS) 20 | } 21 | 22 | dir, errR := os.ReadDir(testRoot) 23 | require.NoError(t, errR) 24 | 25 | for _, entry := range dir { 26 | if !entry.IsDir() { 27 | continue 28 | } 29 | 30 | t.Setenv("MOCKTAIL_TEST_PATH", filepath.Join(testRoot, entry.Name())) 31 | 32 | output, err := exec.Command("go", "run", ".").CombinedOutput() 33 | t.Log(string(output)) 34 | 35 | require.NoError(t, err) 36 | } 37 | 38 | errW := filepath.WalkDir(testRoot, func(path string, d fs.DirEntry, errW error) error { 39 | if errW != nil { 40 | return errW 41 | } 42 | 43 | if d.IsDir() || d.Name() != outputMockFile { 44 | return nil 45 | } 46 | 47 | genBytes, err := os.ReadFile(path) 48 | require.NoError(t, err) 49 | 50 | goldenBytes, err := os.ReadFile(path + ".golden") 51 | require.NoError(t, err) 52 | 53 | assert.Equal(t, string(goldenBytes), string(genBytes)) 54 | 55 | return nil 56 | }) 57 | require.NoError(t, errW) 58 | 59 | for _, entry := range dir { 60 | if !entry.IsDir() { 61 | continue 62 | } 63 | 64 | cmd := exec.Command("go", "test", "-v", "./...") 65 | cmd.Dir = filepath.Join(testRoot, entry.Name()) 66 | 67 | output, err := cmd.CombinedOutput() 68 | t.Log(string(output)) 69 | 70 | require.NoError(t, err) 71 | } 72 | } 73 | 74 | func TestMocktail_exported(t *testing.T) { 75 | const testRoot = "./testdata/exported" 76 | 77 | if runtime.GOOS == "windows" { 78 | t.Skip(runtime.GOOS) 79 | } 80 | 81 | dir, errR := os.ReadDir(testRoot) 82 | require.NoError(t, errR) 83 | 84 | for _, entry := range dir { 85 | if !entry.IsDir() { 86 | continue 87 | } 88 | 89 | t.Setenv("MOCKTAIL_TEST_PATH", filepath.Join(testRoot, entry.Name())) 90 | 91 | output, err := exec.Command("go", "run", ".", "-e").CombinedOutput() 92 | t.Log(string(output)) 93 | 94 | require.NoError(t, err) 95 | } 96 | 97 | errW := filepath.WalkDir(testRoot, func(path string, d fs.DirEntry, errW error) error { 98 | if errW != nil { 99 | return errW 100 | } 101 | 102 | if d.IsDir() || d.Name() != outputMockFile { 103 | return nil 104 | } 105 | 106 | genBytes, err := os.ReadFile(path) 107 | require.NoError(t, err) 108 | 109 | goldenBytes, err := os.ReadFile(path + ".golden") 110 | require.NoError(t, err) 111 | 112 | assert.Equal(t, string(goldenBytes), string(genBytes)) 113 | 114 | return nil 115 | }) 116 | require.NoError(t, errW) 117 | 118 | for _, entry := range dir { 119 | if !entry.IsDir() { 120 | continue 121 | } 122 | 123 | cmd := exec.Command("go", "test", "-v", "./...") 124 | cmd.Dir = filepath.Join(testRoot, entry.Name()) 125 | 126 | output, err := cmd.CombinedOutput() 127 | t.Log(string(output)) 128 | 129 | require.NoError(t, err) 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /mocktail.go: -------------------------------------------------------------------------------- 1 | // package main Naive code generator that creates mock implementation using `testify.mock`. 2 | package main 3 | 4 | import ( 5 | "bufio" 6 | "bytes" 7 | "flag" 8 | "fmt" 9 | "go/format" 10 | "go/types" 11 | "io/fs" 12 | "log" 13 | "os" 14 | "path" 15 | "path/filepath" 16 | "strings" 17 | 18 | "golang.org/x/tools/go/packages" 19 | ) 20 | 21 | const ( 22 | srcMockFile = "mock_test.go" 23 | outputMockFile = "mock_gen_test.go" 24 | outputExportedMockFile = "mock_gen.go" 25 | ) 26 | 27 | const contextType = "context.Context" 28 | 29 | const commentTagPattern = "// mocktail:" 30 | 31 | // PackageDesc represent a package. 32 | type PackageDesc struct { 33 | Pkg *types.Package 34 | Imports map[string]struct{} 35 | Interfaces []InterfaceDesc 36 | } 37 | 38 | // InterfaceDesc represent an interface. 39 | type InterfaceDesc struct { 40 | Name string 41 | Methods []*types.Func 42 | } 43 | 44 | func main() { 45 | info, err := getModuleInfo(os.Getenv("MOCKTAIL_TEST_PATH")) 46 | if err != nil { 47 | log.Fatal("get module path", err) 48 | } 49 | 50 | var exported bool 51 | flag.BoolVar(&exported, "e", false, "generate exported mocks") 52 | flag.Parse() 53 | 54 | root := info.Dir 55 | 56 | err = os.Chdir(root) 57 | if err != nil { 58 | log.Fatalf("Chdir: %v", err) 59 | } 60 | 61 | model, err := walk(root, info.Path) 62 | if err != nil { 63 | log.Fatalf("walk: %v", err) 64 | } 65 | 66 | if len(model) == 0 { 67 | return 68 | } 69 | 70 | err = generate(model, exported) 71 | if err != nil { 72 | log.Fatalf("generate: %v", err) 73 | } 74 | } 75 | 76 | //nolint:gocognit,gocyclo // The complexity is expected. 77 | func walk(root, moduleName string) (map[string]PackageDesc, error) { 78 | model := make(map[string]PackageDesc) 79 | 80 | err := filepath.WalkDir(root, func(fp string, d fs.DirEntry, err error) error { 81 | if err != nil { 82 | return err 83 | } 84 | 85 | if d.IsDir() { 86 | if d.Name() == "testdata" || d.Name() == "vendor" { 87 | return filepath.SkipDir 88 | } 89 | 90 | return nil 91 | } 92 | 93 | if d.Name() != srcMockFile { 94 | return nil 95 | } 96 | 97 | file, err := os.Open(fp) 98 | if err != nil { 99 | return err 100 | } 101 | 102 | packageDesc := PackageDesc{Imports: map[string]struct{}{}} 103 | 104 | scanner := bufio.NewScanner(file) 105 | for scanner.Scan() { 106 | line := scanner.Text() 107 | if line == "" { 108 | continue 109 | } 110 | 111 | i := strings.Index(line, commentTagPattern) 112 | if i <= -1 { 113 | continue 114 | } 115 | 116 | interfaceName := line[i+len(commentTagPattern):] 117 | 118 | var importPath string 119 | if index := strings.LastIndex(interfaceName, "."); index > 0 { 120 | importPath = path.Join(moduleName, interfaceName[:index]) 121 | 122 | interfaceName = interfaceName[index+1:] 123 | } else { 124 | filePkgName, err := filepath.Rel(root, filepath.Dir(fp)) 125 | if err != nil { 126 | return err 127 | } 128 | 129 | importPath = path.Join(moduleName, filePkgName) 130 | } 131 | 132 | pkgs, err := packages.Load( 133 | &packages.Config{ 134 | Mode: packages.NeedTypes, 135 | Dir: root, 136 | }, 137 | importPath, 138 | ) 139 | if err != nil { 140 | return fmt.Errorf("load package %q: %w", importPath, err) 141 | } 142 | 143 | // Only one package specified by the import path has been loaded. 144 | lookup := pkgs[0].Types.Scope().Lookup(interfaceName) 145 | if lookup == nil { 146 | log.Printf("Unable to find: %s", interfaceName) 147 | continue 148 | } 149 | 150 | if packageDesc.Pkg == nil { 151 | packageDesc.Pkg = lookup.Pkg() 152 | } 153 | 154 | interfaceDesc := InterfaceDesc{Name: interfaceName} 155 | 156 | interfaceType, ok := lookup.Type().Underlying().(*types.Interface) 157 | if !ok { 158 | return fmt.Errorf("type %q in %q is not an interface", lookup.Type(), fp) 159 | } 160 | 161 | for i := range interfaceType.NumMethods() { 162 | method := interfaceType.Method(i) 163 | 164 | interfaceDesc.Methods = append(interfaceDesc.Methods, method) 165 | 166 | for _, imp := range getMethodImports(method, packageDesc.Pkg.Path()) { 167 | packageDesc.Imports[imp] = struct{}{} 168 | } 169 | } 170 | 171 | packageDesc.Interfaces = append(packageDesc.Interfaces, interfaceDesc) 172 | } 173 | 174 | if len(packageDesc.Interfaces) > 0 { 175 | model[fp] = packageDesc 176 | } 177 | 178 | return nil 179 | }) 180 | if err != nil { 181 | return nil, fmt.Errorf("walk dir: %w", err) 182 | } 183 | 184 | return model, nil 185 | } 186 | 187 | func getMethodImports(method *types.Func, importPath string) []string { 188 | signature := method.Type().(*types.Signature) 189 | 190 | var imports []string 191 | 192 | for _, imp := range getTupleImports(signature.Params(), signature.Results()) { 193 | if imp != "" && imp != importPath { 194 | imports = append(imports, imp) 195 | } 196 | } 197 | 198 | return imports 199 | } 200 | 201 | func getTupleImports(tuples ...*types.Tuple) []string { 202 | var imports []string 203 | 204 | for _, tuple := range tuples { 205 | for i := range tuple.Len() { 206 | imports = append(imports, getTypeImports(tuple.At(i).Type())...) 207 | } 208 | } 209 | 210 | return imports 211 | } 212 | 213 | func getTypeImports(t types.Type) []string { 214 | switch v := t.(type) { 215 | case *types.Basic: 216 | return []string{""} 217 | 218 | case *types.Slice: 219 | return getTypeImports(v.Elem()) 220 | 221 | case *types.Array: 222 | return getTypeImports(v.Elem()) 223 | 224 | case *types.Struct: 225 | var imports []string 226 | for i := range v.NumFields() { 227 | imports = append(imports, getTypeImports(v.Field(i).Type())...) 228 | } 229 | return imports 230 | 231 | case *types.Map: 232 | imports := getTypeImports(v.Key()) 233 | imports = append(imports, getTypeImports(v.Elem())...) 234 | return imports 235 | 236 | case *types.Named: 237 | if v.Obj().Pkg() == nil { 238 | return []string{""} 239 | } 240 | 241 | return []string{v.Obj().Pkg().Path()} 242 | 243 | case *types.Pointer: 244 | return getTypeImports(v.Elem()) 245 | 246 | case *types.Interface: 247 | return []string{""} 248 | 249 | case *types.Signature: 250 | return getTupleImports(v.Params(), v.Results()) 251 | 252 | case *types.Chan: 253 | return []string{""} 254 | 255 | default: 256 | panic(fmt.Sprintf("OOPS %[1]T %[1]s", t)) 257 | } 258 | } 259 | 260 | func generate(model map[string]PackageDesc, exported bool) error { 261 | for fp, pkgDesc := range model { 262 | buffer := bytes.NewBufferString("") 263 | 264 | err := writeImports(buffer, pkgDesc) 265 | if err != nil { 266 | return err 267 | } 268 | 269 | for _, interfaceDesc := range pkgDesc.Interfaces { 270 | err = writeMockBase(buffer, interfaceDesc.Name, exported) 271 | if err != nil { 272 | return err 273 | } 274 | 275 | _, _ = buffer.WriteString("\n") 276 | 277 | for _, method := range interfaceDesc.Methods { 278 | signature := method.Type().(*types.Signature) 279 | 280 | syrup := Syrup{ 281 | PkgPath: pkgDesc.Pkg.Path(), 282 | InterfaceName: interfaceDesc.Name, 283 | Method: method, 284 | Signature: signature, 285 | } 286 | 287 | err = syrup.MockMethod(buffer) 288 | if err != nil { 289 | return err 290 | } 291 | 292 | err = syrup.Call(buffer, interfaceDesc.Methods) 293 | if err != nil { 294 | return err 295 | } 296 | } 297 | } 298 | 299 | // gofmt 300 | source, err := format.Source(buffer.Bytes()) 301 | if err != nil { 302 | log.Println(buffer.String()) 303 | return fmt.Errorf("source: %w", err) 304 | } 305 | 306 | fileName := outputMockFile 307 | if exported { 308 | fileName = outputExportedMockFile 309 | } 310 | 311 | out := filepath.Join(filepath.Dir(fp), fileName) 312 | 313 | log.Println(out) 314 | 315 | err = os.WriteFile(out, source, 0o640) 316 | if err != nil { 317 | return fmt.Errorf("write file: %w", err) 318 | } 319 | } 320 | 321 | return nil 322 | } 323 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [2022] [Traefik Labs] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /syrup.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "fmt" 5 | "go/types" 6 | "io" 7 | "sort" 8 | "strings" 9 | "text/template" 10 | 11 | "github.com/ettle/strcase" 12 | ) 13 | 14 | const ( 15 | templateImports = `// Code generated by mocktail; DO NOT EDIT. 16 | 17 | package {{ .Name }} 18 | 19 | {{ if .Imports }}import ( 20 | {{- range $index, $import := .Imports }} 21 | {{ if $import }}"{{ $import }}"{{ else }}{{end}} 22 | {{- end}} 23 | ){{end}} 24 | ` 25 | 26 | templateMockBase = ` 27 | // {{ .InterfaceName | ToGoCamel }}Mock mock of {{ .InterfaceName }}. 28 | type {{ .InterfaceName | ToGoCamel }}Mock struct { mock.Mock } 29 | 30 | // {{.ConstructorPrefix}}{{ .InterfaceName | ToGoPascal }}Mock creates a new {{ .InterfaceName | ToGoCamel }}Mock. 31 | func {{.ConstructorPrefix}}{{ .InterfaceName | ToGoPascal }}Mock(tb testing.TB) *{{ .InterfaceName | ToGoCamel }}Mock { 32 | tb.Helper() 33 | 34 | m := &{{ .InterfaceName | ToGoCamel }}Mock{} 35 | m.Mock.Test(tb) 36 | 37 | tb.Cleanup(func() { m.AssertExpectations(tb) }) 38 | 39 | return m 40 | } 41 | ` 42 | 43 | templateCallBase = ` 44 | type {{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call struct{ 45 | *mock.Call 46 | Parent *{{ .InterfaceName | ToGoCamel }}Mock 47 | } 48 | 49 | 50 | func (_c *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call) Panic(msg string) *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call { 51 | _c.Call = _c.Call.Panic(msg) 52 | return _c 53 | } 54 | 55 | func (_c *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call) Once() *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call { 56 | _c.Call = _c.Call.Once() 57 | return _c 58 | } 59 | 60 | func (_c *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call) Twice() *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call { 61 | _c.Call = _c.Call.Twice() 62 | return _c 63 | } 64 | 65 | func (_c *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call) Times(i int) *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call { 66 | _c.Call = _c.Call.Times(i) 67 | return _c 68 | } 69 | 70 | func (_c *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call) WaitUntil(w <-chan time.Time) *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call { 71 | _c.Call = _c.Call.WaitUntil(w) 72 | return _c 73 | } 74 | 75 | func (_c *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call) After(d time.Duration) *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call { 76 | _c.Call = _c.Call.After(d) 77 | return _c 78 | } 79 | 80 | func (_c *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call) Run(fn func(args mock.Arguments)) *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call { 81 | _c.Call = _c.Call.Run(fn) 82 | return _c 83 | } 84 | 85 | func (_c *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call) Maybe() *{{ .InterfaceName | ToGoCamel }}{{ .MethodName }}Call { 86 | _c.Call = _c.Call.Maybe() 87 | return _c 88 | } 89 | 90 | ` 91 | ) 92 | 93 | // Syrup generates method mocks and mock.Call wrapper. 94 | type Syrup struct { 95 | PkgPath string 96 | InterfaceName string 97 | Method *types.Func 98 | Signature *types.Signature 99 | } 100 | 101 | // MockMethod generates method mocks. 102 | func (s Syrup) MockMethod(writer io.Writer) error { 103 | err := s.mockedMethod(writer) 104 | if err != nil { 105 | return err 106 | } 107 | 108 | err = s.methodOn(writer) 109 | if err != nil { 110 | return err 111 | } 112 | 113 | return s.methodOnRaw(writer) 114 | } 115 | 116 | func (s Syrup) mockedMethod(writer io.Writer) error { 117 | w := &Writer{writer: writer} 118 | 119 | w.Printf("func (_m *%sMock) %s(", strcase.ToGoCamel(s.InterfaceName), s.Method.Name()) 120 | 121 | params := s.Signature.Params() 122 | 123 | var argNames []string 124 | for i := range params.Len() { 125 | param := params.At(i) 126 | 127 | if param.Type().String() == contextType { 128 | w.Print("_") 129 | } else { 130 | name := getParamName(param, i) 131 | w.Print(name) 132 | argNames = append(argNames, name) 133 | } 134 | 135 | w.Print(" " + s.getTypeName(param.Type(), i == params.Len()-1)) 136 | 137 | if i+1 < params.Len() { 138 | w.Print(", ") 139 | } 140 | } 141 | 142 | w.Print(") ") 143 | 144 | results := s.Signature.Results() 145 | 146 | if results.Len() > 1 { 147 | w.Print("(") 148 | } 149 | 150 | for i := range results.Len() { 151 | w.Print(s.getTypeName(results.At(i).Type(), false)) 152 | if i+1 < results.Len() { 153 | w.Print(", ") 154 | } 155 | } 156 | 157 | if results.Len() > 1 { 158 | w.Print(")") 159 | } 160 | 161 | w.Println(" {") 162 | 163 | w.Print("\t") 164 | if results.Len() > 0 { 165 | w.Print("_ret := ") 166 | } 167 | w.Printf("_m.Called(%s)\n", strings.Join(argNames, ", ")) 168 | 169 | s.writeReturnsFnCaller(w, argNames, params, results) 170 | 171 | for i := range results.Len() { 172 | if i == 0 { 173 | w.Println() 174 | } 175 | 176 | rType := results.At(i).Type() 177 | 178 | w.Printf("\t%s", getResultName(results.At(i), i)) 179 | 180 | switch rType.String() { 181 | case "string", "int", "bool", "error": 182 | w.Printf("\t := _ret.%s(%d)\n", strcase.ToPascal(rType.String()), i) 183 | default: 184 | name := s.getTypeName(rType, false) 185 | w.Printf(", _ := _ret.Get(%d).(%s)\n", i, name) 186 | } 187 | } 188 | 189 | for i := range results.Len() { 190 | if i == 0 { 191 | w.Println() 192 | w.Print("\treturn ") 193 | } 194 | 195 | w.Print(getResultName(results.At(i), i)) 196 | 197 | if i+1 < results.Len() { 198 | w.Print(", ") 199 | } else { 200 | w.Println() 201 | } 202 | } 203 | 204 | w.Println("}") 205 | w.Println() 206 | 207 | return w.Err() 208 | } 209 | 210 | func (s Syrup) writeReturnsFnCaller(w *Writer, argNames []string, params, results *types.Tuple) { 211 | if results.Len() > 0 { 212 | w.Println() 213 | w.Printf("\tif _rf, ok := _ret.Get(0).(%s); ok {\n", s.createFuncSignature(params, results)) 214 | w.Printf("\t\treturn _rf(%s", strings.Join(argNames, ", ")) 215 | if s.Signature.Variadic() { 216 | w.Print("...") 217 | } 218 | w.Println(")") 219 | w.Println("\t}") 220 | } 221 | } 222 | 223 | func (s Syrup) methodOn(writer io.Writer) error { 224 | w := &Writer{writer: writer} 225 | 226 | structBaseName := strcase.ToGoCamel(s.InterfaceName) 227 | 228 | w.Printf("func (_m *%sMock) On%s(", structBaseName, s.Method.Name()) 229 | 230 | params := s.Signature.Params() 231 | 232 | var argNames []string 233 | for i := range params.Len() { 234 | param := params.At(i) 235 | 236 | if param.Type().String() == contextType { 237 | continue 238 | } 239 | 240 | name := getParamName(param, i) 241 | 242 | w.Print(name) 243 | 244 | if _, ok := param.Type().(*types.Signature); ok { 245 | argNames = append(argNames, "mock.Anything") 246 | } else { 247 | argNames = append(argNames, name) 248 | } 249 | 250 | w.Print(" " + s.getTypeName(param.Type(), i == params.Len()-1)) 251 | 252 | if i+1 < params.Len() { 253 | w.Print(", ") 254 | } 255 | } 256 | 257 | w.Printf(") *%s%sCall {\n", structBaseName, s.Method.Name()) 258 | 259 | w.Printf(` return &%s%sCall{Call: _m.Mock.On("%s", %s), Parent: _m}`, 260 | structBaseName, s.Method.Name(), s.Method.Name(), strings.Join(argNames, ", ")) 261 | 262 | w.Println() 263 | w.Println("}") 264 | w.Println() 265 | 266 | return w.Err() 267 | } 268 | 269 | func (s Syrup) methodOnRaw(writer io.Writer) error { 270 | w := &Writer{writer: writer} 271 | 272 | structBaseName := strcase.ToGoCamel(s.InterfaceName) 273 | 274 | w.Printf("func (_m *%sMock) On%sRaw(", structBaseName, s.Method.Name()) 275 | 276 | params := s.Signature.Params() 277 | 278 | var argNames []string 279 | for i := range params.Len() { 280 | param := params.At(i) 281 | 282 | if param.Type().String() == contextType { 283 | continue 284 | } 285 | 286 | name := getParamName(param, i) 287 | 288 | w.Print(name) 289 | 290 | if _, ok := param.Type().(*types.Signature); ok { 291 | argNames = append(argNames, "mock.Anything") 292 | } else { 293 | argNames = append(argNames, name) 294 | } 295 | 296 | w.Print(" interface{}") 297 | 298 | if i+1 < params.Len() { 299 | w.Print(", ") 300 | } 301 | } 302 | 303 | w.Printf(") *%s%sCall {\n", structBaseName, s.Method.Name()) 304 | 305 | w.Printf(` return &%s%sCall{Call: _m.Mock.On("%s", %s), Parent: _m}`, 306 | structBaseName, s.Method.Name(), s.Method.Name(), strings.Join(argNames, ", ")) 307 | 308 | w.Println() 309 | w.Println("}") 310 | w.Println() 311 | 312 | return w.Err() 313 | } 314 | 315 | // Call generates mock.Call wrapper. 316 | func (s Syrup) Call(writer io.Writer, methods []*types.Func) error { 317 | err := s.callBase(writer) 318 | if err != nil { 319 | return err 320 | } 321 | 322 | err = s.typedReturns(writer) 323 | if err != nil { 324 | return err 325 | } 326 | 327 | err = s.returnsFn(writer) 328 | if err != nil { 329 | return err 330 | } 331 | 332 | err = s.typedRun(writer) 333 | if err != nil { 334 | return err 335 | } 336 | 337 | err = s.callMethodsOn(writer, methods) 338 | if err != nil { 339 | return err 340 | } 341 | 342 | return s.callMethodOnRaw(writer, methods) 343 | } 344 | 345 | func (s Syrup) callBase(writer io.Writer) error { 346 | base := template.New("templateCallBase").Funcs(template.FuncMap{ 347 | "ToGoCamel": strcase.ToGoCamel, 348 | "ToGoPascal": strcase.ToGoPascal, 349 | }) 350 | 351 | tmpl, err := base.Parse(templateCallBase) 352 | if err != nil { 353 | return err 354 | } 355 | 356 | data := map[string]string{ 357 | "InterfaceName": s.InterfaceName, 358 | "MethodName": s.Method.Name(), 359 | } 360 | 361 | return tmpl.Execute(writer, data) 362 | } 363 | 364 | func (s Syrup) typedReturns(writer io.Writer) error { 365 | w := &Writer{writer: writer} 366 | 367 | results := s.Signature.Results() 368 | if results.Len() <= 0 { 369 | return nil 370 | } 371 | 372 | structBaseName := strcase.ToGoCamel(s.InterfaceName) 373 | 374 | w.Printf("func (_c *%s%sCall) TypedReturns(", structBaseName, s.Method.Name()) 375 | 376 | var returnNames string 377 | for i := range results.Len() { 378 | rName := string(rune(int('a') + i)) 379 | 380 | w.Printf("%s %s", rName, s.getTypeName(results.At(i).Type(), false)) 381 | returnNames += rName 382 | 383 | if i+1 < results.Len() { 384 | w.Print(", ") 385 | returnNames += ", " 386 | } 387 | } 388 | 389 | w.Printf(") *%s%sCall {\n", structBaseName, s.Method.Name()) 390 | w.Printf("\t_c.Call = _c.Return(%s)\n", returnNames) 391 | w.Println("\treturn _c") 392 | w.Println("}") 393 | w.Println() 394 | 395 | return w.Err() 396 | } 397 | 398 | func (s Syrup) typedRun(writer io.Writer) error { 399 | w := &Writer{writer: writer} 400 | 401 | params := s.Signature.Params() 402 | 403 | structBaseName := strcase.ToGoCamel(s.InterfaceName) 404 | 405 | w.Printf("func (_c *%[1]s%[2]sCall) TypedRun(fn %[3]s) *%[1]s%[2]sCall {\n", 406 | structBaseName, s.Method.Name(), s.createFuncSignature(params, nil)) 407 | w.Println("\t_c.Call = _c.Call.Run(func(args mock.Arguments) {") 408 | 409 | var pos int 410 | var paramNames []string 411 | for i := range params.Len() { 412 | param := params.At(i) 413 | pType := param.Type() 414 | 415 | if pType.String() == contextType { 416 | continue 417 | } 418 | 419 | paramName := "_" + getParamName(param, i) 420 | 421 | paramNames = append(paramNames, paramName) 422 | 423 | switch pType.String() { 424 | case "string", "int", "bool", "error": 425 | w.Printf("\t\t%s := args.%s(%d)\n", paramName, strcase.ToPascal(pType.String()), pos) 426 | default: 427 | w.Printf("\t\t%s, _ := args.Get(%d).(%s)\n", paramName, pos, s.getTypeName(pType, false)) 428 | } 429 | 430 | pos++ 431 | } 432 | 433 | w.Printf("\t\tfn(%s", strings.Join(paramNames, ", ")) 434 | if s.Signature.Variadic() { 435 | w.Print("...") 436 | } 437 | w.Println(")") 438 | 439 | w.Println("\t})") 440 | w.Println("\treturn _c") 441 | w.Println("}") 442 | w.Println() 443 | 444 | return w.Err() 445 | } 446 | 447 | func (s Syrup) returnsFn(writer io.Writer) error { 448 | w := &Writer{writer: writer} 449 | 450 | results := s.Signature.Results() 451 | if results.Len() < 1 { 452 | return nil 453 | } 454 | 455 | params := s.Signature.Params() 456 | 457 | structBaseName := strcase.ToGoCamel(s.InterfaceName) 458 | 459 | w.Printf("func (_c *%[1]s%[2]sCall) ReturnsFn(fn %[3]s) *%[1]s%[2]sCall {\n", 460 | structBaseName, s.Method.Name(), s.createFuncSignature(params, results)) 461 | w.Println("\t_c.Call = _c.Return(fn)") 462 | w.Println("\treturn _c") 463 | w.Println("}") 464 | w.Println() 465 | 466 | return w.Err() 467 | } 468 | 469 | func (s Syrup) callMethodsOn(writer io.Writer, methods []*types.Func) error { 470 | w := &Writer{writer: writer} 471 | 472 | callType := fmt.Sprintf("%s%sCall", strcase.ToGoCamel(s.InterfaceName), s.Method.Name()) 473 | 474 | for _, method := range methods { 475 | sign := method.Type().(*types.Signature) 476 | 477 | w.Printf("func (_c *%s) On%s(", callType, method.Name()) 478 | 479 | params := sign.Params() 480 | 481 | var argNames []string 482 | for i := range params.Len() { 483 | param := params.At(i) 484 | 485 | if param.Type().String() == contextType { 486 | continue 487 | } 488 | 489 | name := getParamName(param, i) 490 | 491 | w.Print(name) 492 | argNames = append(argNames, name) 493 | 494 | w.Print(" " + s.getTypeName(param.Type(), i == params.Len()-1)) 495 | 496 | if i+1 < params.Len() { 497 | w.Print(", ") 498 | } 499 | } 500 | 501 | w.Printf(") *%s%sCall {\n", strcase.ToGoCamel(s.InterfaceName), method.Name()) 502 | 503 | w.Printf("\treturn _c.Parent.On%s(%s", method.Name(), strings.Join(argNames, ", ")) 504 | if sign.Variadic() { 505 | w.Print("...") 506 | } 507 | w.Println(")") 508 | w.Println("}") 509 | w.Println() 510 | } 511 | 512 | return w.Err() 513 | } 514 | 515 | func (s Syrup) callMethodOnRaw(writer io.Writer, methods []*types.Func) error { 516 | w := &Writer{writer: writer} 517 | 518 | callType := fmt.Sprintf("%s%sCall", strcase.ToGoCamel(s.InterfaceName), s.Method.Name()) 519 | 520 | for _, method := range methods { 521 | sign := method.Type().(*types.Signature) 522 | 523 | w.Printf("func (_c *%s) On%sRaw(", callType, method.Name()) 524 | 525 | params := sign.Params() 526 | 527 | var argNames []string 528 | for i := range params.Len() { 529 | param := params.At(i) 530 | 531 | if param.Type().String() == contextType { 532 | continue 533 | } 534 | 535 | name := getParamName(param, i) 536 | 537 | w.Print(name) 538 | argNames = append(argNames, name) 539 | 540 | w.Print(" interface{}") 541 | 542 | if i+1 < params.Len() { 543 | w.Print(", ") 544 | } 545 | } 546 | 547 | w.Printf(") *%s%sCall {\n", strcase.ToGoCamel(s.InterfaceName), method.Name()) 548 | 549 | w.Printf("\treturn _c.Parent.On%sRaw(%s)\n", method.Name(), strings.Join(argNames, ", ")) 550 | w.Println("}") 551 | w.Println() 552 | } 553 | 554 | return w.Err() 555 | } 556 | 557 | func (s Syrup) getTypeName(t types.Type, last bool) string { 558 | switch v := t.(type) { 559 | case *types.Basic: 560 | return v.Name() 561 | 562 | case *types.Slice: 563 | if s.Signature.Variadic() && last { 564 | return "..." + s.getTypeName(v.Elem(), false) 565 | } 566 | 567 | return "[]" + s.getTypeName(v.Elem(), false) 568 | 569 | case *types.Map: 570 | return "map[" + s.getTypeName(v.Key(), false) + "]" + s.getTypeName(v.Elem(), false) 571 | 572 | case *types.Named: 573 | return s.getNamedTypeName(v) 574 | 575 | case *types.Pointer: 576 | return "*" + s.getTypeName(v.Elem(), false) 577 | 578 | case *types.Struct: 579 | return v.String() 580 | 581 | case *types.Interface: 582 | return v.String() 583 | 584 | case *types.Signature: 585 | fn := "func(" + strings.Join(s.getTupleTypes(v.Params()), ",") + ")" 586 | 587 | if v.Results().Len() > 0 { 588 | fn += " (" + strings.Join(s.getTupleTypes(v.Results()), ",") + ")" 589 | } 590 | 591 | return fn 592 | 593 | case *types.Chan: 594 | return s.getChanTypeName(v) 595 | 596 | case *types.Array: 597 | return fmt.Sprintf("[%d]%s", v.Len(), s.getTypeName(v.Elem(), false)) 598 | 599 | default: 600 | panic(fmt.Sprintf("OOPS %[1]T %[1]s", t)) 601 | } 602 | } 603 | 604 | func (s Syrup) getTupleTypes(t *types.Tuple) []string { 605 | var tupleTypes []string 606 | for i := range t.Len() { 607 | param := t.At(i) 608 | 609 | tupleTypes = append(tupleTypes, s.getTypeName(param.Type(), false)) 610 | } 611 | 612 | return tupleTypes 613 | } 614 | 615 | func (s Syrup) getNamedTypeName(t *types.Named) string { 616 | if t.Obj() != nil && t.Obj().Pkg() != nil { 617 | if t.Obj().Pkg().Path() == s.PkgPath { 618 | return t.Obj().Name() 619 | } 620 | return t.Obj().Pkg().Name() + "." + t.Obj().Name() 621 | } 622 | 623 | name := t.String() 624 | 625 | i := strings.LastIndex(t.String(), "/") 626 | if i > -1 { 627 | name = name[i+1:] 628 | } 629 | return name 630 | } 631 | 632 | func (s Syrup) getChanTypeName(t *types.Chan) string { 633 | var typ string 634 | switch t.Dir() { 635 | case types.SendRecv: 636 | typ = "chan" 637 | case types.SendOnly: 638 | typ = "chan<-" 639 | case types.RecvOnly: 640 | typ = "<-chan" 641 | } 642 | 643 | return typ + " " + s.getTypeName(t.Elem(), false) 644 | } 645 | 646 | func (s Syrup) createFuncSignature(params, results *types.Tuple) string { 647 | fnSign := "func(" 648 | for i := range params.Len() { 649 | param := params.At(i) 650 | if param.Type().String() == contextType { 651 | continue 652 | } 653 | 654 | fnSign += s.getTypeName(param.Type(), i == params.Len()-1) 655 | 656 | if i+1 < params.Len() { 657 | fnSign += ", " 658 | } 659 | } 660 | fnSign += ") " 661 | 662 | if results != nil { 663 | fnSign += "(" 664 | for i := range results.Len() { 665 | rType := results.At(i).Type() 666 | fnSign += s.getTypeName(rType, false) 667 | if i+1 < results.Len() { 668 | fnSign += ", " 669 | } 670 | } 671 | fnSign += ")" 672 | } 673 | 674 | return fnSign 675 | } 676 | 677 | func writeImports(writer io.Writer, descPkg PackageDesc) error { 678 | base := template.New("templateImports") 679 | 680 | tmpl, err := base.Parse(templateImports) 681 | if err != nil { 682 | return err 683 | } 684 | 685 | data := map[string]interface{}{ 686 | "Name": descPkg.Pkg.Name(), 687 | "Imports": quickGoImports(descPkg), 688 | } 689 | return tmpl.Execute(writer, data) 690 | } 691 | 692 | func writeMockBase(writer io.Writer, interfaceName string, exported bool) error { 693 | base := template.New("templateMockBase").Funcs(template.FuncMap{ 694 | "ToGoCamel": strcase.ToGoCamel, 695 | "ToGoPascal": strcase.ToGoPascal, 696 | }) 697 | 698 | constructorPrefix := "new" 699 | if exported { 700 | constructorPrefix = "New" 701 | } 702 | 703 | tmpl, err := base.Parse(templateMockBase) 704 | if err != nil { 705 | return err 706 | } 707 | 708 | return tmpl.Execute(writer, map[string]interface{}{"InterfaceName": interfaceName, "ConstructorPrefix": constructorPrefix}) 709 | } 710 | 711 | func quickGoImports(descPkg PackageDesc) []string { 712 | imports := []string{ 713 | "", // to separate std imports than the others 714 | } 715 | 716 | descPkg.Imports["testing"] = struct{}{} // require by test 717 | descPkg.Imports["time"] = struct{}{} // require by `WaitUntil(w <-chan time.Time)` 718 | descPkg.Imports["github.com/stretchr/testify/mock"] = struct{}{} // require by mock 719 | 720 | for imp := range descPkg.Imports { 721 | imports = append(imports, imp) 722 | } 723 | 724 | sort.Slice(imports, func(i, j int) bool { 725 | if imports[i] == "" { 726 | return strings.Contains(imports[j], ".") 727 | } 728 | if imports[j] == "" { 729 | return !strings.Contains(imports[i], ".") 730 | } 731 | 732 | if strings.Contains(imports[i], ".") && !strings.Contains(imports[j], ".") { 733 | return false 734 | } 735 | if !strings.Contains(imports[i], ".") && strings.Contains(imports[j], ".") { 736 | return true 737 | } 738 | 739 | return imports[i] < imports[j] 740 | }) 741 | 742 | return imports 743 | } 744 | 745 | func getParamName(tVar *types.Var, i int) string { 746 | if tVar.Name() == "" { 747 | return fmt.Sprintf("%sParam", string(rune('a'+i))) 748 | } 749 | return tVar.Name() 750 | } 751 | 752 | func getResultName(tVar *types.Var, i int) string { 753 | if tVar.Name() == "" { 754 | return fmt.Sprintf("_r%s%d", string(rune('a'+i)), i) 755 | } 756 | return tVar.Name() 757 | } 758 | 759 | // Writer is a wrapper around Print+ functions. 760 | type Writer struct { 761 | writer io.Writer 762 | err error 763 | } 764 | 765 | // Err returns error from the other methods. 766 | func (w *Writer) Err() error { 767 | return w.err 768 | } 769 | 770 | // Print formats using the default formats for its operands and writes to standard output. 771 | func (w *Writer) Print(a ...interface{}) { 772 | if w.err != nil { 773 | return 774 | } 775 | 776 | _, w.err = fmt.Fprint(w.writer, a...) 777 | } 778 | 779 | // Printf formats according to a format specifier and writes to standard output. 780 | func (w *Writer) Printf(pattern string, a ...interface{}) { 781 | if w.err != nil { 782 | return 783 | } 784 | 785 | _, w.err = fmt.Fprintf(w.writer, pattern, a...) 786 | } 787 | 788 | // Println formats using the default formats for its operands and writes to standard output. 789 | func (w *Writer) Println(a ...interface{}) { 790 | if w.err != nil { 791 | return 792 | } 793 | 794 | _, w.err = fmt.Fprintln(w.writer, a...) 795 | } 796 | -------------------------------------------------------------------------------- /testdata/exported/b/c/mock_gen.go: -------------------------------------------------------------------------------- 1 | // Code generated by mocktail; DO NOT EDIT. 2 | 3 | package c 4 | 5 | import ( 6 | "bytes" 7 | "context" 8 | "testing" 9 | "time" 10 | 11 | "github.com/stretchr/testify/mock" 12 | "golang.org/x/mod/module" 13 | ) 14 | 15 | // pineappleMock mock of Pineapple. 16 | type pineappleMock struct{ mock.Mock } 17 | 18 | // NewPineappleMock creates a new pineappleMock. 19 | func NewPineappleMock(tb testing.TB) *pineappleMock { 20 | tb.Helper() 21 | 22 | m := &pineappleMock{} 23 | m.Mock.Test(tb) 24 | 25 | tb.Cleanup(func() { m.AssertExpectations(tb) }) 26 | 27 | return m 28 | } 29 | 30 | func (_m *pineappleMock) Coo(_ context.Context, bParam string, cParam Water) Water { 31 | _ret := _m.Called(bParam, cParam) 32 | 33 | if _rf, ok := _ret.Get(0).(func(string, Water) Water); ok { 34 | return _rf(bParam, cParam) 35 | } 36 | 37 | _ra0, _ := _ret.Get(0).(Water) 38 | 39 | return _ra0 40 | } 41 | 42 | func (_m *pineappleMock) OnCoo(bParam string, cParam Water) *pineappleCooCall { 43 | return &pineappleCooCall{Call: _m.Mock.On("Coo", bParam, cParam), Parent: _m} 44 | } 45 | 46 | func (_m *pineappleMock) OnCooRaw(bParam interface{}, cParam interface{}) *pineappleCooCall { 47 | return &pineappleCooCall{Call: _m.Mock.On("Coo", bParam, cParam), Parent: _m} 48 | } 49 | 50 | type pineappleCooCall struct { 51 | *mock.Call 52 | Parent *pineappleMock 53 | } 54 | 55 | func (_c *pineappleCooCall) Panic(msg string) *pineappleCooCall { 56 | _c.Call = _c.Call.Panic(msg) 57 | return _c 58 | } 59 | 60 | func (_c *pineappleCooCall) Once() *pineappleCooCall { 61 | _c.Call = _c.Call.Once() 62 | return _c 63 | } 64 | 65 | func (_c *pineappleCooCall) Twice() *pineappleCooCall { 66 | _c.Call = _c.Call.Twice() 67 | return _c 68 | } 69 | 70 | func (_c *pineappleCooCall) Times(i int) *pineappleCooCall { 71 | _c.Call = _c.Call.Times(i) 72 | return _c 73 | } 74 | 75 | func (_c *pineappleCooCall) WaitUntil(w <-chan time.Time) *pineappleCooCall { 76 | _c.Call = _c.Call.WaitUntil(w) 77 | return _c 78 | } 79 | 80 | func (_c *pineappleCooCall) After(d time.Duration) *pineappleCooCall { 81 | _c.Call = _c.Call.After(d) 82 | return _c 83 | } 84 | 85 | func (_c *pineappleCooCall) Run(fn func(args mock.Arguments)) *pineappleCooCall { 86 | _c.Call = _c.Call.Run(fn) 87 | return _c 88 | } 89 | 90 | func (_c *pineappleCooCall) Maybe() *pineappleCooCall { 91 | _c.Call = _c.Call.Maybe() 92 | return _c 93 | } 94 | 95 | func (_c *pineappleCooCall) TypedReturns(a Water) *pineappleCooCall { 96 | _c.Call = _c.Return(a) 97 | return _c 98 | } 99 | 100 | func (_c *pineappleCooCall) ReturnsFn(fn func(string, Water) Water) *pineappleCooCall { 101 | _c.Call = _c.Return(fn) 102 | return _c 103 | } 104 | 105 | func (_c *pineappleCooCall) TypedRun(fn func(string, Water)) *pineappleCooCall { 106 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 107 | _bParam := args.String(0) 108 | _cParam, _ := args.Get(1).(Water) 109 | fn(_bParam, _cParam) 110 | }) 111 | return _c 112 | } 113 | 114 | func (_c *pineappleCooCall) OnCoo(bParam string, cParam Water) *pineappleCooCall { 115 | return _c.Parent.OnCoo(bParam, cParam) 116 | } 117 | 118 | func (_c *pineappleCooCall) OnGoo() *pineappleGooCall { 119 | return _c.Parent.OnGoo() 120 | } 121 | 122 | func (_c *pineappleCooCall) OnHello(bar Water) *pineappleHelloCall { 123 | return _c.Parent.OnHello(bar) 124 | } 125 | 126 | func (_c *pineappleCooCall) OnWorld() *pineappleWorldCall { 127 | return _c.Parent.OnWorld() 128 | } 129 | 130 | func (_c *pineappleCooCall) OnCooRaw(bParam interface{}, cParam interface{}) *pineappleCooCall { 131 | return _c.Parent.OnCooRaw(bParam, cParam) 132 | } 133 | 134 | func (_c *pineappleCooCall) OnGooRaw() *pineappleGooCall { 135 | return _c.Parent.OnGooRaw() 136 | } 137 | 138 | func (_c *pineappleCooCall) OnHelloRaw(bar interface{}) *pineappleHelloCall { 139 | return _c.Parent.OnHelloRaw(bar) 140 | } 141 | 142 | func (_c *pineappleCooCall) OnWorldRaw() *pineappleWorldCall { 143 | return _c.Parent.OnWorldRaw() 144 | } 145 | 146 | func (_m *pineappleMock) Goo() (string, int, Water) { 147 | _ret := _m.Called() 148 | 149 | if _rf, ok := _ret.Get(0).(func() (string, int, Water)); ok { 150 | return _rf() 151 | } 152 | 153 | _ra0 := _ret.String(0) 154 | _rb1 := _ret.Int(1) 155 | _rc2, _ := _ret.Get(2).(Water) 156 | 157 | return _ra0, _rb1, _rc2 158 | } 159 | 160 | func (_m *pineappleMock) OnGoo() *pineappleGooCall { 161 | return &pineappleGooCall{Call: _m.Mock.On("Goo"), Parent: _m} 162 | } 163 | 164 | func (_m *pineappleMock) OnGooRaw() *pineappleGooCall { 165 | return &pineappleGooCall{Call: _m.Mock.On("Goo"), Parent: _m} 166 | } 167 | 168 | type pineappleGooCall struct { 169 | *mock.Call 170 | Parent *pineappleMock 171 | } 172 | 173 | func (_c *pineappleGooCall) Panic(msg string) *pineappleGooCall { 174 | _c.Call = _c.Call.Panic(msg) 175 | return _c 176 | } 177 | 178 | func (_c *pineappleGooCall) Once() *pineappleGooCall { 179 | _c.Call = _c.Call.Once() 180 | return _c 181 | } 182 | 183 | func (_c *pineappleGooCall) Twice() *pineappleGooCall { 184 | _c.Call = _c.Call.Twice() 185 | return _c 186 | } 187 | 188 | func (_c *pineappleGooCall) Times(i int) *pineappleGooCall { 189 | _c.Call = _c.Call.Times(i) 190 | return _c 191 | } 192 | 193 | func (_c *pineappleGooCall) WaitUntil(w <-chan time.Time) *pineappleGooCall { 194 | _c.Call = _c.Call.WaitUntil(w) 195 | return _c 196 | } 197 | 198 | func (_c *pineappleGooCall) After(d time.Duration) *pineappleGooCall { 199 | _c.Call = _c.Call.After(d) 200 | return _c 201 | } 202 | 203 | func (_c *pineappleGooCall) Run(fn func(args mock.Arguments)) *pineappleGooCall { 204 | _c.Call = _c.Call.Run(fn) 205 | return _c 206 | } 207 | 208 | func (_c *pineappleGooCall) Maybe() *pineappleGooCall { 209 | _c.Call = _c.Call.Maybe() 210 | return _c 211 | } 212 | 213 | func (_c *pineappleGooCall) TypedReturns(a string, b int, c Water) *pineappleGooCall { 214 | _c.Call = _c.Return(a, b, c) 215 | return _c 216 | } 217 | 218 | func (_c *pineappleGooCall) ReturnsFn(fn func() (string, int, Water)) *pineappleGooCall { 219 | _c.Call = _c.Return(fn) 220 | return _c 221 | } 222 | 223 | func (_c *pineappleGooCall) TypedRun(fn func()) *pineappleGooCall { 224 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 225 | fn() 226 | }) 227 | return _c 228 | } 229 | 230 | func (_c *pineappleGooCall) OnCoo(bParam string, cParam Water) *pineappleCooCall { 231 | return _c.Parent.OnCoo(bParam, cParam) 232 | } 233 | 234 | func (_c *pineappleGooCall) OnGoo() *pineappleGooCall { 235 | return _c.Parent.OnGoo() 236 | } 237 | 238 | func (_c *pineappleGooCall) OnHello(bar Water) *pineappleHelloCall { 239 | return _c.Parent.OnHello(bar) 240 | } 241 | 242 | func (_c *pineappleGooCall) OnWorld() *pineappleWorldCall { 243 | return _c.Parent.OnWorld() 244 | } 245 | 246 | func (_c *pineappleGooCall) OnCooRaw(bParam interface{}, cParam interface{}) *pineappleCooCall { 247 | return _c.Parent.OnCooRaw(bParam, cParam) 248 | } 249 | 250 | func (_c *pineappleGooCall) OnGooRaw() *pineappleGooCall { 251 | return _c.Parent.OnGooRaw() 252 | } 253 | 254 | func (_c *pineappleGooCall) OnHelloRaw(bar interface{}) *pineappleHelloCall { 255 | return _c.Parent.OnHelloRaw(bar) 256 | } 257 | 258 | func (_c *pineappleGooCall) OnWorldRaw() *pineappleWorldCall { 259 | return _c.Parent.OnWorldRaw() 260 | } 261 | 262 | func (_m *pineappleMock) Hello(bar Water) string { 263 | _ret := _m.Called(bar) 264 | 265 | if _rf, ok := _ret.Get(0).(func(Water) string); ok { 266 | return _rf(bar) 267 | } 268 | 269 | _ra0 := _ret.String(0) 270 | 271 | return _ra0 272 | } 273 | 274 | func (_m *pineappleMock) OnHello(bar Water) *pineappleHelloCall { 275 | return &pineappleHelloCall{Call: _m.Mock.On("Hello", bar), Parent: _m} 276 | } 277 | 278 | func (_m *pineappleMock) OnHelloRaw(bar interface{}) *pineappleHelloCall { 279 | return &pineappleHelloCall{Call: _m.Mock.On("Hello", bar), Parent: _m} 280 | } 281 | 282 | type pineappleHelloCall struct { 283 | *mock.Call 284 | Parent *pineappleMock 285 | } 286 | 287 | func (_c *pineappleHelloCall) Panic(msg string) *pineappleHelloCall { 288 | _c.Call = _c.Call.Panic(msg) 289 | return _c 290 | } 291 | 292 | func (_c *pineappleHelloCall) Once() *pineappleHelloCall { 293 | _c.Call = _c.Call.Once() 294 | return _c 295 | } 296 | 297 | func (_c *pineappleHelloCall) Twice() *pineappleHelloCall { 298 | _c.Call = _c.Call.Twice() 299 | return _c 300 | } 301 | 302 | func (_c *pineappleHelloCall) Times(i int) *pineappleHelloCall { 303 | _c.Call = _c.Call.Times(i) 304 | return _c 305 | } 306 | 307 | func (_c *pineappleHelloCall) WaitUntil(w <-chan time.Time) *pineappleHelloCall { 308 | _c.Call = _c.Call.WaitUntil(w) 309 | return _c 310 | } 311 | 312 | func (_c *pineappleHelloCall) After(d time.Duration) *pineappleHelloCall { 313 | _c.Call = _c.Call.After(d) 314 | return _c 315 | } 316 | 317 | func (_c *pineappleHelloCall) Run(fn func(args mock.Arguments)) *pineappleHelloCall { 318 | _c.Call = _c.Call.Run(fn) 319 | return _c 320 | } 321 | 322 | func (_c *pineappleHelloCall) Maybe() *pineappleHelloCall { 323 | _c.Call = _c.Call.Maybe() 324 | return _c 325 | } 326 | 327 | func (_c *pineappleHelloCall) TypedReturns(a string) *pineappleHelloCall { 328 | _c.Call = _c.Return(a) 329 | return _c 330 | } 331 | 332 | func (_c *pineappleHelloCall) ReturnsFn(fn func(Water) string) *pineappleHelloCall { 333 | _c.Call = _c.Return(fn) 334 | return _c 335 | } 336 | 337 | func (_c *pineappleHelloCall) TypedRun(fn func(Water)) *pineappleHelloCall { 338 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 339 | _bar, _ := args.Get(0).(Water) 340 | fn(_bar) 341 | }) 342 | return _c 343 | } 344 | 345 | func (_c *pineappleHelloCall) OnCoo(bParam string, cParam Water) *pineappleCooCall { 346 | return _c.Parent.OnCoo(bParam, cParam) 347 | } 348 | 349 | func (_c *pineappleHelloCall) OnGoo() *pineappleGooCall { 350 | return _c.Parent.OnGoo() 351 | } 352 | 353 | func (_c *pineappleHelloCall) OnHello(bar Water) *pineappleHelloCall { 354 | return _c.Parent.OnHello(bar) 355 | } 356 | 357 | func (_c *pineappleHelloCall) OnWorld() *pineappleWorldCall { 358 | return _c.Parent.OnWorld() 359 | } 360 | 361 | func (_c *pineappleHelloCall) OnCooRaw(bParam interface{}, cParam interface{}) *pineappleCooCall { 362 | return _c.Parent.OnCooRaw(bParam, cParam) 363 | } 364 | 365 | func (_c *pineappleHelloCall) OnGooRaw() *pineappleGooCall { 366 | return _c.Parent.OnGooRaw() 367 | } 368 | 369 | func (_c *pineappleHelloCall) OnHelloRaw(bar interface{}) *pineappleHelloCall { 370 | return _c.Parent.OnHelloRaw(bar) 371 | } 372 | 373 | func (_c *pineappleHelloCall) OnWorldRaw() *pineappleWorldCall { 374 | return _c.Parent.OnWorldRaw() 375 | } 376 | 377 | func (_m *pineappleMock) World() string { 378 | _ret := _m.Called() 379 | 380 | if _rf, ok := _ret.Get(0).(func() string); ok { 381 | return _rf() 382 | } 383 | 384 | _ra0 := _ret.String(0) 385 | 386 | return _ra0 387 | } 388 | 389 | func (_m *pineappleMock) OnWorld() *pineappleWorldCall { 390 | return &pineappleWorldCall{Call: _m.Mock.On("World"), Parent: _m} 391 | } 392 | 393 | func (_m *pineappleMock) OnWorldRaw() *pineappleWorldCall { 394 | return &pineappleWorldCall{Call: _m.Mock.On("World"), Parent: _m} 395 | } 396 | 397 | type pineappleWorldCall struct { 398 | *mock.Call 399 | Parent *pineappleMock 400 | } 401 | 402 | func (_c *pineappleWorldCall) Panic(msg string) *pineappleWorldCall { 403 | _c.Call = _c.Call.Panic(msg) 404 | return _c 405 | } 406 | 407 | func (_c *pineappleWorldCall) Once() *pineappleWorldCall { 408 | _c.Call = _c.Call.Once() 409 | return _c 410 | } 411 | 412 | func (_c *pineappleWorldCall) Twice() *pineappleWorldCall { 413 | _c.Call = _c.Call.Twice() 414 | return _c 415 | } 416 | 417 | func (_c *pineappleWorldCall) Times(i int) *pineappleWorldCall { 418 | _c.Call = _c.Call.Times(i) 419 | return _c 420 | } 421 | 422 | func (_c *pineappleWorldCall) WaitUntil(w <-chan time.Time) *pineappleWorldCall { 423 | _c.Call = _c.Call.WaitUntil(w) 424 | return _c 425 | } 426 | 427 | func (_c *pineappleWorldCall) After(d time.Duration) *pineappleWorldCall { 428 | _c.Call = _c.Call.After(d) 429 | return _c 430 | } 431 | 432 | func (_c *pineappleWorldCall) Run(fn func(args mock.Arguments)) *pineappleWorldCall { 433 | _c.Call = _c.Call.Run(fn) 434 | return _c 435 | } 436 | 437 | func (_c *pineappleWorldCall) Maybe() *pineappleWorldCall { 438 | _c.Call = _c.Call.Maybe() 439 | return _c 440 | } 441 | 442 | func (_c *pineappleWorldCall) TypedReturns(a string) *pineappleWorldCall { 443 | _c.Call = _c.Return(a) 444 | return _c 445 | } 446 | 447 | func (_c *pineappleWorldCall) ReturnsFn(fn func() string) *pineappleWorldCall { 448 | _c.Call = _c.Return(fn) 449 | return _c 450 | } 451 | 452 | func (_c *pineappleWorldCall) TypedRun(fn func()) *pineappleWorldCall { 453 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 454 | fn() 455 | }) 456 | return _c 457 | } 458 | 459 | func (_c *pineappleWorldCall) OnCoo(bParam string, cParam Water) *pineappleCooCall { 460 | return _c.Parent.OnCoo(bParam, cParam) 461 | } 462 | 463 | func (_c *pineappleWorldCall) OnGoo() *pineappleGooCall { 464 | return _c.Parent.OnGoo() 465 | } 466 | 467 | func (_c *pineappleWorldCall) OnHello(bar Water) *pineappleHelloCall { 468 | return _c.Parent.OnHello(bar) 469 | } 470 | 471 | func (_c *pineappleWorldCall) OnWorld() *pineappleWorldCall { 472 | return _c.Parent.OnWorld() 473 | } 474 | 475 | func (_c *pineappleWorldCall) OnCooRaw(bParam interface{}, cParam interface{}) *pineappleCooCall { 476 | return _c.Parent.OnCooRaw(bParam, cParam) 477 | } 478 | 479 | func (_c *pineappleWorldCall) OnGooRaw() *pineappleGooCall { 480 | return _c.Parent.OnGooRaw() 481 | } 482 | 483 | func (_c *pineappleWorldCall) OnHelloRaw(bar interface{}) *pineappleHelloCall { 484 | return _c.Parent.OnHelloRaw(bar) 485 | } 486 | 487 | func (_c *pineappleWorldCall) OnWorldRaw() *pineappleWorldCall { 488 | return _c.Parent.OnWorldRaw() 489 | } 490 | 491 | // coconutMock mock of Coconut. 492 | type coconutMock struct{ mock.Mock } 493 | 494 | // NewCoconutMock creates a new coconutMock. 495 | func NewCoconutMock(tb testing.TB) *coconutMock { 496 | tb.Helper() 497 | 498 | m := &coconutMock{} 499 | m.Mock.Test(tb) 500 | 501 | tb.Cleanup(func() { m.AssertExpectations(tb) }) 502 | 503 | return m 504 | } 505 | 506 | func (_m *coconutMock) Boo(src *bytes.Buffer) time.Duration { 507 | _ret := _m.Called(src) 508 | 509 | if _rf, ok := _ret.Get(0).(func(*bytes.Buffer) time.Duration); ok { 510 | return _rf(src) 511 | } 512 | 513 | _ra0, _ := _ret.Get(0).(time.Duration) 514 | 515 | return _ra0 516 | } 517 | 518 | func (_m *coconutMock) OnBoo(src *bytes.Buffer) *coconutBooCall { 519 | return &coconutBooCall{Call: _m.Mock.On("Boo", src), Parent: _m} 520 | } 521 | 522 | func (_m *coconutMock) OnBooRaw(src interface{}) *coconutBooCall { 523 | return &coconutBooCall{Call: _m.Mock.On("Boo", src), Parent: _m} 524 | } 525 | 526 | type coconutBooCall struct { 527 | *mock.Call 528 | Parent *coconutMock 529 | } 530 | 531 | func (_c *coconutBooCall) Panic(msg string) *coconutBooCall { 532 | _c.Call = _c.Call.Panic(msg) 533 | return _c 534 | } 535 | 536 | func (_c *coconutBooCall) Once() *coconutBooCall { 537 | _c.Call = _c.Call.Once() 538 | return _c 539 | } 540 | 541 | func (_c *coconutBooCall) Twice() *coconutBooCall { 542 | _c.Call = _c.Call.Twice() 543 | return _c 544 | } 545 | 546 | func (_c *coconutBooCall) Times(i int) *coconutBooCall { 547 | _c.Call = _c.Call.Times(i) 548 | return _c 549 | } 550 | 551 | func (_c *coconutBooCall) WaitUntil(w <-chan time.Time) *coconutBooCall { 552 | _c.Call = _c.Call.WaitUntil(w) 553 | return _c 554 | } 555 | 556 | func (_c *coconutBooCall) After(d time.Duration) *coconutBooCall { 557 | _c.Call = _c.Call.After(d) 558 | return _c 559 | } 560 | 561 | func (_c *coconutBooCall) Run(fn func(args mock.Arguments)) *coconutBooCall { 562 | _c.Call = _c.Call.Run(fn) 563 | return _c 564 | } 565 | 566 | func (_c *coconutBooCall) Maybe() *coconutBooCall { 567 | _c.Call = _c.Call.Maybe() 568 | return _c 569 | } 570 | 571 | func (_c *coconutBooCall) TypedReturns(a time.Duration) *coconutBooCall { 572 | _c.Call = _c.Return(a) 573 | return _c 574 | } 575 | 576 | func (_c *coconutBooCall) ReturnsFn(fn func(*bytes.Buffer) time.Duration) *coconutBooCall { 577 | _c.Call = _c.Return(fn) 578 | return _c 579 | } 580 | 581 | func (_c *coconutBooCall) TypedRun(fn func(*bytes.Buffer)) *coconutBooCall { 582 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 583 | _src, _ := args.Get(0).(*bytes.Buffer) 584 | fn(_src) 585 | }) 586 | return _c 587 | } 588 | 589 | func (_c *coconutBooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { 590 | return _c.Parent.OnBoo(src) 591 | } 592 | 593 | func (_c *coconutBooCall) OnDoo(src time.Duration) *coconutDooCall { 594 | return _c.Parent.OnDoo(src) 595 | } 596 | 597 | func (_c *coconutBooCall) OnFoo(st Strawberry) *coconutFooCall { 598 | return _c.Parent.OnFoo(st) 599 | } 600 | 601 | func (_c *coconutBooCall) OnGoo(st string) *coconutGooCall { 602 | return _c.Parent.OnGoo(st) 603 | } 604 | 605 | func (_c *coconutBooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 606 | return _c.Parent.OnHoo(aParam, bParam, cParam) 607 | } 608 | 609 | func (_c *coconutBooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 610 | return _c.Parent.OnJoo(aParam, bParam, cParam) 611 | } 612 | 613 | func (_c *coconutBooCall) OnKoo(src string) *coconutKooCall { 614 | return _c.Parent.OnKoo(src) 615 | } 616 | 617 | func (_c *coconutBooCall) OnLoo(st string, values []int) *coconutLooCall { 618 | return _c.Parent.OnLoo(st, values...) 619 | } 620 | 621 | func (_c *coconutBooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 622 | return _c.Parent.OnMoo(fn) 623 | } 624 | 625 | func (_c *coconutBooCall) OnToo(src string) *coconutTooCall { 626 | return _c.Parent.OnToo(src) 627 | } 628 | 629 | func (_c *coconutBooCall) OnVoo(src *module.Version) *coconutVooCall { 630 | return _c.Parent.OnVoo(src) 631 | } 632 | 633 | func (_c *coconutBooCall) OnYoo(st string) *coconutYooCall { 634 | return _c.Parent.OnYoo(st) 635 | } 636 | 637 | func (_c *coconutBooCall) OnZoo(st interface{}) *coconutZooCall { 638 | return _c.Parent.OnZoo(st) 639 | } 640 | 641 | func (_c *coconutBooCall) OnBooRaw(src interface{}) *coconutBooCall { 642 | return _c.Parent.OnBooRaw(src) 643 | } 644 | 645 | func (_c *coconutBooCall) OnDooRaw(src interface{}) *coconutDooCall { 646 | return _c.Parent.OnDooRaw(src) 647 | } 648 | 649 | func (_c *coconutBooCall) OnFooRaw(st interface{}) *coconutFooCall { 650 | return _c.Parent.OnFooRaw(st) 651 | } 652 | 653 | func (_c *coconutBooCall) OnGooRaw(st interface{}) *coconutGooCall { 654 | return _c.Parent.OnGooRaw(st) 655 | } 656 | 657 | func (_c *coconutBooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 658 | return _c.Parent.OnHooRaw(aParam, bParam, cParam) 659 | } 660 | 661 | func (_c *coconutBooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 662 | return _c.Parent.OnJooRaw(aParam, bParam, cParam) 663 | } 664 | 665 | func (_c *coconutBooCall) OnKooRaw(src interface{}) *coconutKooCall { 666 | return _c.Parent.OnKooRaw(src) 667 | } 668 | 669 | func (_c *coconutBooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 670 | return _c.Parent.OnLooRaw(st, values) 671 | } 672 | 673 | func (_c *coconutBooCall) OnMooRaw(fn interface{}) *coconutMooCall { 674 | return _c.Parent.OnMooRaw(fn) 675 | } 676 | 677 | func (_c *coconutBooCall) OnTooRaw(src interface{}) *coconutTooCall { 678 | return _c.Parent.OnTooRaw(src) 679 | } 680 | 681 | func (_c *coconutBooCall) OnVooRaw(src interface{}) *coconutVooCall { 682 | return _c.Parent.OnVooRaw(src) 683 | } 684 | 685 | func (_c *coconutBooCall) OnYooRaw(st interface{}) *coconutYooCall { 686 | return _c.Parent.OnYooRaw(st) 687 | } 688 | 689 | func (_c *coconutBooCall) OnZooRaw(st interface{}) *coconutZooCall { 690 | return _c.Parent.OnZooRaw(st) 691 | } 692 | 693 | func (_m *coconutMock) Doo(src time.Duration) time.Duration { 694 | _ret := _m.Called(src) 695 | 696 | if _rf, ok := _ret.Get(0).(func(time.Duration) time.Duration); ok { 697 | return _rf(src) 698 | } 699 | 700 | _ra0, _ := _ret.Get(0).(time.Duration) 701 | 702 | return _ra0 703 | } 704 | 705 | func (_m *coconutMock) OnDoo(src time.Duration) *coconutDooCall { 706 | return &coconutDooCall{Call: _m.Mock.On("Doo", src), Parent: _m} 707 | } 708 | 709 | func (_m *coconutMock) OnDooRaw(src interface{}) *coconutDooCall { 710 | return &coconutDooCall{Call: _m.Mock.On("Doo", src), Parent: _m} 711 | } 712 | 713 | type coconutDooCall struct { 714 | *mock.Call 715 | Parent *coconutMock 716 | } 717 | 718 | func (_c *coconutDooCall) Panic(msg string) *coconutDooCall { 719 | _c.Call = _c.Call.Panic(msg) 720 | return _c 721 | } 722 | 723 | func (_c *coconutDooCall) Once() *coconutDooCall { 724 | _c.Call = _c.Call.Once() 725 | return _c 726 | } 727 | 728 | func (_c *coconutDooCall) Twice() *coconutDooCall { 729 | _c.Call = _c.Call.Twice() 730 | return _c 731 | } 732 | 733 | func (_c *coconutDooCall) Times(i int) *coconutDooCall { 734 | _c.Call = _c.Call.Times(i) 735 | return _c 736 | } 737 | 738 | func (_c *coconutDooCall) WaitUntil(w <-chan time.Time) *coconutDooCall { 739 | _c.Call = _c.Call.WaitUntil(w) 740 | return _c 741 | } 742 | 743 | func (_c *coconutDooCall) After(d time.Duration) *coconutDooCall { 744 | _c.Call = _c.Call.After(d) 745 | return _c 746 | } 747 | 748 | func (_c *coconutDooCall) Run(fn func(args mock.Arguments)) *coconutDooCall { 749 | _c.Call = _c.Call.Run(fn) 750 | return _c 751 | } 752 | 753 | func (_c *coconutDooCall) Maybe() *coconutDooCall { 754 | _c.Call = _c.Call.Maybe() 755 | return _c 756 | } 757 | 758 | func (_c *coconutDooCall) TypedReturns(a time.Duration) *coconutDooCall { 759 | _c.Call = _c.Return(a) 760 | return _c 761 | } 762 | 763 | func (_c *coconutDooCall) ReturnsFn(fn func(time.Duration) time.Duration) *coconutDooCall { 764 | _c.Call = _c.Return(fn) 765 | return _c 766 | } 767 | 768 | func (_c *coconutDooCall) TypedRun(fn func(time.Duration)) *coconutDooCall { 769 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 770 | _src, _ := args.Get(0).(time.Duration) 771 | fn(_src) 772 | }) 773 | return _c 774 | } 775 | 776 | func (_c *coconutDooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { 777 | return _c.Parent.OnBoo(src) 778 | } 779 | 780 | func (_c *coconutDooCall) OnDoo(src time.Duration) *coconutDooCall { 781 | return _c.Parent.OnDoo(src) 782 | } 783 | 784 | func (_c *coconutDooCall) OnFoo(st Strawberry) *coconutFooCall { 785 | return _c.Parent.OnFoo(st) 786 | } 787 | 788 | func (_c *coconutDooCall) OnGoo(st string) *coconutGooCall { 789 | return _c.Parent.OnGoo(st) 790 | } 791 | 792 | func (_c *coconutDooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 793 | return _c.Parent.OnHoo(aParam, bParam, cParam) 794 | } 795 | 796 | func (_c *coconutDooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 797 | return _c.Parent.OnJoo(aParam, bParam, cParam) 798 | } 799 | 800 | func (_c *coconutDooCall) OnKoo(src string) *coconutKooCall { 801 | return _c.Parent.OnKoo(src) 802 | } 803 | 804 | func (_c *coconutDooCall) OnLoo(st string, values []int) *coconutLooCall { 805 | return _c.Parent.OnLoo(st, values...) 806 | } 807 | 808 | func (_c *coconutDooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 809 | return _c.Parent.OnMoo(fn) 810 | } 811 | 812 | func (_c *coconutDooCall) OnToo(src string) *coconutTooCall { 813 | return _c.Parent.OnToo(src) 814 | } 815 | 816 | func (_c *coconutDooCall) OnVoo(src *module.Version) *coconutVooCall { 817 | return _c.Parent.OnVoo(src) 818 | } 819 | 820 | func (_c *coconutDooCall) OnYoo(st string) *coconutYooCall { 821 | return _c.Parent.OnYoo(st) 822 | } 823 | 824 | func (_c *coconutDooCall) OnZoo(st interface{}) *coconutZooCall { 825 | return _c.Parent.OnZoo(st) 826 | } 827 | 828 | func (_c *coconutDooCall) OnBooRaw(src interface{}) *coconutBooCall { 829 | return _c.Parent.OnBooRaw(src) 830 | } 831 | 832 | func (_c *coconutDooCall) OnDooRaw(src interface{}) *coconutDooCall { 833 | return _c.Parent.OnDooRaw(src) 834 | } 835 | 836 | func (_c *coconutDooCall) OnFooRaw(st interface{}) *coconutFooCall { 837 | return _c.Parent.OnFooRaw(st) 838 | } 839 | 840 | func (_c *coconutDooCall) OnGooRaw(st interface{}) *coconutGooCall { 841 | return _c.Parent.OnGooRaw(st) 842 | } 843 | 844 | func (_c *coconutDooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 845 | return _c.Parent.OnHooRaw(aParam, bParam, cParam) 846 | } 847 | 848 | func (_c *coconutDooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 849 | return _c.Parent.OnJooRaw(aParam, bParam, cParam) 850 | } 851 | 852 | func (_c *coconutDooCall) OnKooRaw(src interface{}) *coconutKooCall { 853 | return _c.Parent.OnKooRaw(src) 854 | } 855 | 856 | func (_c *coconutDooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 857 | return _c.Parent.OnLooRaw(st, values) 858 | } 859 | 860 | func (_c *coconutDooCall) OnMooRaw(fn interface{}) *coconutMooCall { 861 | return _c.Parent.OnMooRaw(fn) 862 | } 863 | 864 | func (_c *coconutDooCall) OnTooRaw(src interface{}) *coconutTooCall { 865 | return _c.Parent.OnTooRaw(src) 866 | } 867 | 868 | func (_c *coconutDooCall) OnVooRaw(src interface{}) *coconutVooCall { 869 | return _c.Parent.OnVooRaw(src) 870 | } 871 | 872 | func (_c *coconutDooCall) OnYooRaw(st interface{}) *coconutYooCall { 873 | return _c.Parent.OnYooRaw(st) 874 | } 875 | 876 | func (_c *coconutDooCall) OnZooRaw(st interface{}) *coconutZooCall { 877 | return _c.Parent.OnZooRaw(st) 878 | } 879 | 880 | func (_m *coconutMock) Foo(st Strawberry) string { 881 | _ret := _m.Called(st) 882 | 883 | if _rf, ok := _ret.Get(0).(func(Strawberry) string); ok { 884 | return _rf(st) 885 | } 886 | 887 | _ra0 := _ret.String(0) 888 | 889 | return _ra0 890 | } 891 | 892 | func (_m *coconutMock) OnFoo(st Strawberry) *coconutFooCall { 893 | return &coconutFooCall{Call: _m.Mock.On("Foo", st), Parent: _m} 894 | } 895 | 896 | func (_m *coconutMock) OnFooRaw(st interface{}) *coconutFooCall { 897 | return &coconutFooCall{Call: _m.Mock.On("Foo", st), Parent: _m} 898 | } 899 | 900 | type coconutFooCall struct { 901 | *mock.Call 902 | Parent *coconutMock 903 | } 904 | 905 | func (_c *coconutFooCall) Panic(msg string) *coconutFooCall { 906 | _c.Call = _c.Call.Panic(msg) 907 | return _c 908 | } 909 | 910 | func (_c *coconutFooCall) Once() *coconutFooCall { 911 | _c.Call = _c.Call.Once() 912 | return _c 913 | } 914 | 915 | func (_c *coconutFooCall) Twice() *coconutFooCall { 916 | _c.Call = _c.Call.Twice() 917 | return _c 918 | } 919 | 920 | func (_c *coconutFooCall) Times(i int) *coconutFooCall { 921 | _c.Call = _c.Call.Times(i) 922 | return _c 923 | } 924 | 925 | func (_c *coconutFooCall) WaitUntil(w <-chan time.Time) *coconutFooCall { 926 | _c.Call = _c.Call.WaitUntil(w) 927 | return _c 928 | } 929 | 930 | func (_c *coconutFooCall) After(d time.Duration) *coconutFooCall { 931 | _c.Call = _c.Call.After(d) 932 | return _c 933 | } 934 | 935 | func (_c *coconutFooCall) Run(fn func(args mock.Arguments)) *coconutFooCall { 936 | _c.Call = _c.Call.Run(fn) 937 | return _c 938 | } 939 | 940 | func (_c *coconutFooCall) Maybe() *coconutFooCall { 941 | _c.Call = _c.Call.Maybe() 942 | return _c 943 | } 944 | 945 | func (_c *coconutFooCall) TypedReturns(a string) *coconutFooCall { 946 | _c.Call = _c.Return(a) 947 | return _c 948 | } 949 | 950 | func (_c *coconutFooCall) ReturnsFn(fn func(Strawberry) string) *coconutFooCall { 951 | _c.Call = _c.Return(fn) 952 | return _c 953 | } 954 | 955 | func (_c *coconutFooCall) TypedRun(fn func(Strawberry)) *coconutFooCall { 956 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 957 | _st, _ := args.Get(0).(Strawberry) 958 | fn(_st) 959 | }) 960 | return _c 961 | } 962 | 963 | func (_c *coconutFooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { 964 | return _c.Parent.OnBoo(src) 965 | } 966 | 967 | func (_c *coconutFooCall) OnDoo(src time.Duration) *coconutDooCall { 968 | return _c.Parent.OnDoo(src) 969 | } 970 | 971 | func (_c *coconutFooCall) OnFoo(st Strawberry) *coconutFooCall { 972 | return _c.Parent.OnFoo(st) 973 | } 974 | 975 | func (_c *coconutFooCall) OnGoo(st string) *coconutGooCall { 976 | return _c.Parent.OnGoo(st) 977 | } 978 | 979 | func (_c *coconutFooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 980 | return _c.Parent.OnHoo(aParam, bParam, cParam) 981 | } 982 | 983 | func (_c *coconutFooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 984 | return _c.Parent.OnJoo(aParam, bParam, cParam) 985 | } 986 | 987 | func (_c *coconutFooCall) OnKoo(src string) *coconutKooCall { 988 | return _c.Parent.OnKoo(src) 989 | } 990 | 991 | func (_c *coconutFooCall) OnLoo(st string, values []int) *coconutLooCall { 992 | return _c.Parent.OnLoo(st, values...) 993 | } 994 | 995 | func (_c *coconutFooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 996 | return _c.Parent.OnMoo(fn) 997 | } 998 | 999 | func (_c *coconutFooCall) OnToo(src string) *coconutTooCall { 1000 | return _c.Parent.OnToo(src) 1001 | } 1002 | 1003 | func (_c *coconutFooCall) OnVoo(src *module.Version) *coconutVooCall { 1004 | return _c.Parent.OnVoo(src) 1005 | } 1006 | 1007 | func (_c *coconutFooCall) OnYoo(st string) *coconutYooCall { 1008 | return _c.Parent.OnYoo(st) 1009 | } 1010 | 1011 | func (_c *coconutFooCall) OnZoo(st interface{}) *coconutZooCall { 1012 | return _c.Parent.OnZoo(st) 1013 | } 1014 | 1015 | func (_c *coconutFooCall) OnBooRaw(src interface{}) *coconutBooCall { 1016 | return _c.Parent.OnBooRaw(src) 1017 | } 1018 | 1019 | func (_c *coconutFooCall) OnDooRaw(src interface{}) *coconutDooCall { 1020 | return _c.Parent.OnDooRaw(src) 1021 | } 1022 | 1023 | func (_c *coconutFooCall) OnFooRaw(st interface{}) *coconutFooCall { 1024 | return _c.Parent.OnFooRaw(st) 1025 | } 1026 | 1027 | func (_c *coconutFooCall) OnGooRaw(st interface{}) *coconutGooCall { 1028 | return _c.Parent.OnGooRaw(st) 1029 | } 1030 | 1031 | func (_c *coconutFooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 1032 | return _c.Parent.OnHooRaw(aParam, bParam, cParam) 1033 | } 1034 | 1035 | func (_c *coconutFooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 1036 | return _c.Parent.OnJooRaw(aParam, bParam, cParam) 1037 | } 1038 | 1039 | func (_c *coconutFooCall) OnKooRaw(src interface{}) *coconutKooCall { 1040 | return _c.Parent.OnKooRaw(src) 1041 | } 1042 | 1043 | func (_c *coconutFooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 1044 | return _c.Parent.OnLooRaw(st, values) 1045 | } 1046 | 1047 | func (_c *coconutFooCall) OnMooRaw(fn interface{}) *coconutMooCall { 1048 | return _c.Parent.OnMooRaw(fn) 1049 | } 1050 | 1051 | func (_c *coconutFooCall) OnTooRaw(src interface{}) *coconutTooCall { 1052 | return _c.Parent.OnTooRaw(src) 1053 | } 1054 | 1055 | func (_c *coconutFooCall) OnVooRaw(src interface{}) *coconutVooCall { 1056 | return _c.Parent.OnVooRaw(src) 1057 | } 1058 | 1059 | func (_c *coconutFooCall) OnYooRaw(st interface{}) *coconutYooCall { 1060 | return _c.Parent.OnYooRaw(st) 1061 | } 1062 | 1063 | func (_c *coconutFooCall) OnZooRaw(st interface{}) *coconutZooCall { 1064 | return _c.Parent.OnZooRaw(st) 1065 | } 1066 | 1067 | func (_m *coconutMock) Goo(st string) Strawberry { 1068 | _ret := _m.Called(st) 1069 | 1070 | if _rf, ok := _ret.Get(0).(func(string) Strawberry); ok { 1071 | return _rf(st) 1072 | } 1073 | 1074 | _ra0, _ := _ret.Get(0).(Strawberry) 1075 | 1076 | return _ra0 1077 | } 1078 | 1079 | func (_m *coconutMock) OnGoo(st string) *coconutGooCall { 1080 | return &coconutGooCall{Call: _m.Mock.On("Goo", st), Parent: _m} 1081 | } 1082 | 1083 | func (_m *coconutMock) OnGooRaw(st interface{}) *coconutGooCall { 1084 | return &coconutGooCall{Call: _m.Mock.On("Goo", st), Parent: _m} 1085 | } 1086 | 1087 | type coconutGooCall struct { 1088 | *mock.Call 1089 | Parent *coconutMock 1090 | } 1091 | 1092 | func (_c *coconutGooCall) Panic(msg string) *coconutGooCall { 1093 | _c.Call = _c.Call.Panic(msg) 1094 | return _c 1095 | } 1096 | 1097 | func (_c *coconutGooCall) Once() *coconutGooCall { 1098 | _c.Call = _c.Call.Once() 1099 | return _c 1100 | } 1101 | 1102 | func (_c *coconutGooCall) Twice() *coconutGooCall { 1103 | _c.Call = _c.Call.Twice() 1104 | return _c 1105 | } 1106 | 1107 | func (_c *coconutGooCall) Times(i int) *coconutGooCall { 1108 | _c.Call = _c.Call.Times(i) 1109 | return _c 1110 | } 1111 | 1112 | func (_c *coconutGooCall) WaitUntil(w <-chan time.Time) *coconutGooCall { 1113 | _c.Call = _c.Call.WaitUntil(w) 1114 | return _c 1115 | } 1116 | 1117 | func (_c *coconutGooCall) After(d time.Duration) *coconutGooCall { 1118 | _c.Call = _c.Call.After(d) 1119 | return _c 1120 | } 1121 | 1122 | func (_c *coconutGooCall) Run(fn func(args mock.Arguments)) *coconutGooCall { 1123 | _c.Call = _c.Call.Run(fn) 1124 | return _c 1125 | } 1126 | 1127 | func (_c *coconutGooCall) Maybe() *coconutGooCall { 1128 | _c.Call = _c.Call.Maybe() 1129 | return _c 1130 | } 1131 | 1132 | func (_c *coconutGooCall) TypedReturns(a Strawberry) *coconutGooCall { 1133 | _c.Call = _c.Return(a) 1134 | return _c 1135 | } 1136 | 1137 | func (_c *coconutGooCall) ReturnsFn(fn func(string) Strawberry) *coconutGooCall { 1138 | _c.Call = _c.Return(fn) 1139 | return _c 1140 | } 1141 | 1142 | func (_c *coconutGooCall) TypedRun(fn func(string)) *coconutGooCall { 1143 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 1144 | _st := args.String(0) 1145 | fn(_st) 1146 | }) 1147 | return _c 1148 | } 1149 | 1150 | func (_c *coconutGooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { 1151 | return _c.Parent.OnBoo(src) 1152 | } 1153 | 1154 | func (_c *coconutGooCall) OnDoo(src time.Duration) *coconutDooCall { 1155 | return _c.Parent.OnDoo(src) 1156 | } 1157 | 1158 | func (_c *coconutGooCall) OnFoo(st Strawberry) *coconutFooCall { 1159 | return _c.Parent.OnFoo(st) 1160 | } 1161 | 1162 | func (_c *coconutGooCall) OnGoo(st string) *coconutGooCall { 1163 | return _c.Parent.OnGoo(st) 1164 | } 1165 | 1166 | func (_c *coconutGooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 1167 | return _c.Parent.OnHoo(aParam, bParam, cParam) 1168 | } 1169 | 1170 | func (_c *coconutGooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 1171 | return _c.Parent.OnJoo(aParam, bParam, cParam) 1172 | } 1173 | 1174 | func (_c *coconutGooCall) OnKoo(src string) *coconutKooCall { 1175 | return _c.Parent.OnKoo(src) 1176 | } 1177 | 1178 | func (_c *coconutGooCall) OnLoo(st string, values []int) *coconutLooCall { 1179 | return _c.Parent.OnLoo(st, values...) 1180 | } 1181 | 1182 | func (_c *coconutGooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 1183 | return _c.Parent.OnMoo(fn) 1184 | } 1185 | 1186 | func (_c *coconutGooCall) OnToo(src string) *coconutTooCall { 1187 | return _c.Parent.OnToo(src) 1188 | } 1189 | 1190 | func (_c *coconutGooCall) OnVoo(src *module.Version) *coconutVooCall { 1191 | return _c.Parent.OnVoo(src) 1192 | } 1193 | 1194 | func (_c *coconutGooCall) OnYoo(st string) *coconutYooCall { 1195 | return _c.Parent.OnYoo(st) 1196 | } 1197 | 1198 | func (_c *coconutGooCall) OnZoo(st interface{}) *coconutZooCall { 1199 | return _c.Parent.OnZoo(st) 1200 | } 1201 | 1202 | func (_c *coconutGooCall) OnBooRaw(src interface{}) *coconutBooCall { 1203 | return _c.Parent.OnBooRaw(src) 1204 | } 1205 | 1206 | func (_c *coconutGooCall) OnDooRaw(src interface{}) *coconutDooCall { 1207 | return _c.Parent.OnDooRaw(src) 1208 | } 1209 | 1210 | func (_c *coconutGooCall) OnFooRaw(st interface{}) *coconutFooCall { 1211 | return _c.Parent.OnFooRaw(st) 1212 | } 1213 | 1214 | func (_c *coconutGooCall) OnGooRaw(st interface{}) *coconutGooCall { 1215 | return _c.Parent.OnGooRaw(st) 1216 | } 1217 | 1218 | func (_c *coconutGooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 1219 | return _c.Parent.OnHooRaw(aParam, bParam, cParam) 1220 | } 1221 | 1222 | func (_c *coconutGooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 1223 | return _c.Parent.OnJooRaw(aParam, bParam, cParam) 1224 | } 1225 | 1226 | func (_c *coconutGooCall) OnKooRaw(src interface{}) *coconutKooCall { 1227 | return _c.Parent.OnKooRaw(src) 1228 | } 1229 | 1230 | func (_c *coconutGooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 1231 | return _c.Parent.OnLooRaw(st, values) 1232 | } 1233 | 1234 | func (_c *coconutGooCall) OnMooRaw(fn interface{}) *coconutMooCall { 1235 | return _c.Parent.OnMooRaw(fn) 1236 | } 1237 | 1238 | func (_c *coconutGooCall) OnTooRaw(src interface{}) *coconutTooCall { 1239 | return _c.Parent.OnTooRaw(src) 1240 | } 1241 | 1242 | func (_c *coconutGooCall) OnVooRaw(src interface{}) *coconutVooCall { 1243 | return _c.Parent.OnVooRaw(src) 1244 | } 1245 | 1246 | func (_c *coconutGooCall) OnYooRaw(st interface{}) *coconutYooCall { 1247 | return _c.Parent.OnYooRaw(st) 1248 | } 1249 | 1250 | func (_c *coconutGooCall) OnZooRaw(st interface{}) *coconutZooCall { 1251 | return _c.Parent.OnZooRaw(st) 1252 | } 1253 | 1254 | func (_m *coconutMock) Hoo(aParam string, bParam int, cParam Water) { 1255 | _m.Called(aParam, bParam, cParam) 1256 | } 1257 | 1258 | func (_m *coconutMock) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 1259 | return &coconutHooCall{Call: _m.Mock.On("Hoo", aParam, bParam, cParam), Parent: _m} 1260 | } 1261 | 1262 | func (_m *coconutMock) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 1263 | return &coconutHooCall{Call: _m.Mock.On("Hoo", aParam, bParam, cParam), Parent: _m} 1264 | } 1265 | 1266 | type coconutHooCall struct { 1267 | *mock.Call 1268 | Parent *coconutMock 1269 | } 1270 | 1271 | func (_c *coconutHooCall) Panic(msg string) *coconutHooCall { 1272 | _c.Call = _c.Call.Panic(msg) 1273 | return _c 1274 | } 1275 | 1276 | func (_c *coconutHooCall) Once() *coconutHooCall { 1277 | _c.Call = _c.Call.Once() 1278 | return _c 1279 | } 1280 | 1281 | func (_c *coconutHooCall) Twice() *coconutHooCall { 1282 | _c.Call = _c.Call.Twice() 1283 | return _c 1284 | } 1285 | 1286 | func (_c *coconutHooCall) Times(i int) *coconutHooCall { 1287 | _c.Call = _c.Call.Times(i) 1288 | return _c 1289 | } 1290 | 1291 | func (_c *coconutHooCall) WaitUntil(w <-chan time.Time) *coconutHooCall { 1292 | _c.Call = _c.Call.WaitUntil(w) 1293 | return _c 1294 | } 1295 | 1296 | func (_c *coconutHooCall) After(d time.Duration) *coconutHooCall { 1297 | _c.Call = _c.Call.After(d) 1298 | return _c 1299 | } 1300 | 1301 | func (_c *coconutHooCall) Run(fn func(args mock.Arguments)) *coconutHooCall { 1302 | _c.Call = _c.Call.Run(fn) 1303 | return _c 1304 | } 1305 | 1306 | func (_c *coconutHooCall) Maybe() *coconutHooCall { 1307 | _c.Call = _c.Call.Maybe() 1308 | return _c 1309 | } 1310 | 1311 | func (_c *coconutHooCall) TypedRun(fn func(string, int, Water)) *coconutHooCall { 1312 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 1313 | _aParam := args.String(0) 1314 | _bParam := args.Int(1) 1315 | _cParam, _ := args.Get(2).(Water) 1316 | fn(_aParam, _bParam, _cParam) 1317 | }) 1318 | return _c 1319 | } 1320 | 1321 | func (_c *coconutHooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { 1322 | return _c.Parent.OnBoo(src) 1323 | } 1324 | 1325 | func (_c *coconutHooCall) OnDoo(src time.Duration) *coconutDooCall { 1326 | return _c.Parent.OnDoo(src) 1327 | } 1328 | 1329 | func (_c *coconutHooCall) OnFoo(st Strawberry) *coconutFooCall { 1330 | return _c.Parent.OnFoo(st) 1331 | } 1332 | 1333 | func (_c *coconutHooCall) OnGoo(st string) *coconutGooCall { 1334 | return _c.Parent.OnGoo(st) 1335 | } 1336 | 1337 | func (_c *coconutHooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 1338 | return _c.Parent.OnHoo(aParam, bParam, cParam) 1339 | } 1340 | 1341 | func (_c *coconutHooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 1342 | return _c.Parent.OnJoo(aParam, bParam, cParam) 1343 | } 1344 | 1345 | func (_c *coconutHooCall) OnKoo(src string) *coconutKooCall { 1346 | return _c.Parent.OnKoo(src) 1347 | } 1348 | 1349 | func (_c *coconutHooCall) OnLoo(st string, values []int) *coconutLooCall { 1350 | return _c.Parent.OnLoo(st, values...) 1351 | } 1352 | 1353 | func (_c *coconutHooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 1354 | return _c.Parent.OnMoo(fn) 1355 | } 1356 | 1357 | func (_c *coconutHooCall) OnToo(src string) *coconutTooCall { 1358 | return _c.Parent.OnToo(src) 1359 | } 1360 | 1361 | func (_c *coconutHooCall) OnVoo(src *module.Version) *coconutVooCall { 1362 | return _c.Parent.OnVoo(src) 1363 | } 1364 | 1365 | func (_c *coconutHooCall) OnYoo(st string) *coconutYooCall { 1366 | return _c.Parent.OnYoo(st) 1367 | } 1368 | 1369 | func (_c *coconutHooCall) OnZoo(st interface{}) *coconutZooCall { 1370 | return _c.Parent.OnZoo(st) 1371 | } 1372 | 1373 | func (_c *coconutHooCall) OnBooRaw(src interface{}) *coconutBooCall { 1374 | return _c.Parent.OnBooRaw(src) 1375 | } 1376 | 1377 | func (_c *coconutHooCall) OnDooRaw(src interface{}) *coconutDooCall { 1378 | return _c.Parent.OnDooRaw(src) 1379 | } 1380 | 1381 | func (_c *coconutHooCall) OnFooRaw(st interface{}) *coconutFooCall { 1382 | return _c.Parent.OnFooRaw(st) 1383 | } 1384 | 1385 | func (_c *coconutHooCall) OnGooRaw(st interface{}) *coconutGooCall { 1386 | return _c.Parent.OnGooRaw(st) 1387 | } 1388 | 1389 | func (_c *coconutHooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 1390 | return _c.Parent.OnHooRaw(aParam, bParam, cParam) 1391 | } 1392 | 1393 | func (_c *coconutHooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 1394 | return _c.Parent.OnJooRaw(aParam, bParam, cParam) 1395 | } 1396 | 1397 | func (_c *coconutHooCall) OnKooRaw(src interface{}) *coconutKooCall { 1398 | return _c.Parent.OnKooRaw(src) 1399 | } 1400 | 1401 | func (_c *coconutHooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 1402 | return _c.Parent.OnLooRaw(st, values) 1403 | } 1404 | 1405 | func (_c *coconutHooCall) OnMooRaw(fn interface{}) *coconutMooCall { 1406 | return _c.Parent.OnMooRaw(fn) 1407 | } 1408 | 1409 | func (_c *coconutHooCall) OnTooRaw(src interface{}) *coconutTooCall { 1410 | return _c.Parent.OnTooRaw(src) 1411 | } 1412 | 1413 | func (_c *coconutHooCall) OnVooRaw(src interface{}) *coconutVooCall { 1414 | return _c.Parent.OnVooRaw(src) 1415 | } 1416 | 1417 | func (_c *coconutHooCall) OnYooRaw(st interface{}) *coconutYooCall { 1418 | return _c.Parent.OnYooRaw(st) 1419 | } 1420 | 1421 | func (_c *coconutHooCall) OnZooRaw(st interface{}) *coconutZooCall { 1422 | return _c.Parent.OnZooRaw(st) 1423 | } 1424 | 1425 | func (_m *coconutMock) Joo(aParam string, bParam int, cParam Water) (string, int) { 1426 | _ret := _m.Called(aParam, bParam, cParam) 1427 | 1428 | if _rf, ok := _ret.Get(0).(func(string, int, Water) (string, int)); ok { 1429 | return _rf(aParam, bParam, cParam) 1430 | } 1431 | 1432 | _ra0 := _ret.String(0) 1433 | _rb1 := _ret.Int(1) 1434 | 1435 | return _ra0, _rb1 1436 | } 1437 | 1438 | func (_m *coconutMock) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 1439 | return &coconutJooCall{Call: _m.Mock.On("Joo", aParam, bParam, cParam), Parent: _m} 1440 | } 1441 | 1442 | func (_m *coconutMock) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 1443 | return &coconutJooCall{Call: _m.Mock.On("Joo", aParam, bParam, cParam), Parent: _m} 1444 | } 1445 | 1446 | type coconutJooCall struct { 1447 | *mock.Call 1448 | Parent *coconutMock 1449 | } 1450 | 1451 | func (_c *coconutJooCall) Panic(msg string) *coconutJooCall { 1452 | _c.Call = _c.Call.Panic(msg) 1453 | return _c 1454 | } 1455 | 1456 | func (_c *coconutJooCall) Once() *coconutJooCall { 1457 | _c.Call = _c.Call.Once() 1458 | return _c 1459 | } 1460 | 1461 | func (_c *coconutJooCall) Twice() *coconutJooCall { 1462 | _c.Call = _c.Call.Twice() 1463 | return _c 1464 | } 1465 | 1466 | func (_c *coconutJooCall) Times(i int) *coconutJooCall { 1467 | _c.Call = _c.Call.Times(i) 1468 | return _c 1469 | } 1470 | 1471 | func (_c *coconutJooCall) WaitUntil(w <-chan time.Time) *coconutJooCall { 1472 | _c.Call = _c.Call.WaitUntil(w) 1473 | return _c 1474 | } 1475 | 1476 | func (_c *coconutJooCall) After(d time.Duration) *coconutJooCall { 1477 | _c.Call = _c.Call.After(d) 1478 | return _c 1479 | } 1480 | 1481 | func (_c *coconutJooCall) Run(fn func(args mock.Arguments)) *coconutJooCall { 1482 | _c.Call = _c.Call.Run(fn) 1483 | return _c 1484 | } 1485 | 1486 | func (_c *coconutJooCall) Maybe() *coconutJooCall { 1487 | _c.Call = _c.Call.Maybe() 1488 | return _c 1489 | } 1490 | 1491 | func (_c *coconutJooCall) TypedReturns(a string, b int) *coconutJooCall { 1492 | _c.Call = _c.Return(a, b) 1493 | return _c 1494 | } 1495 | 1496 | func (_c *coconutJooCall) ReturnsFn(fn func(string, int, Water) (string, int)) *coconutJooCall { 1497 | _c.Call = _c.Return(fn) 1498 | return _c 1499 | } 1500 | 1501 | func (_c *coconutJooCall) TypedRun(fn func(string, int, Water)) *coconutJooCall { 1502 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 1503 | _aParam := args.String(0) 1504 | _bParam := args.Int(1) 1505 | _cParam, _ := args.Get(2).(Water) 1506 | fn(_aParam, _bParam, _cParam) 1507 | }) 1508 | return _c 1509 | } 1510 | 1511 | func (_c *coconutJooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { 1512 | return _c.Parent.OnBoo(src) 1513 | } 1514 | 1515 | func (_c *coconutJooCall) OnDoo(src time.Duration) *coconutDooCall { 1516 | return _c.Parent.OnDoo(src) 1517 | } 1518 | 1519 | func (_c *coconutJooCall) OnFoo(st Strawberry) *coconutFooCall { 1520 | return _c.Parent.OnFoo(st) 1521 | } 1522 | 1523 | func (_c *coconutJooCall) OnGoo(st string) *coconutGooCall { 1524 | return _c.Parent.OnGoo(st) 1525 | } 1526 | 1527 | func (_c *coconutJooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 1528 | return _c.Parent.OnHoo(aParam, bParam, cParam) 1529 | } 1530 | 1531 | func (_c *coconutJooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 1532 | return _c.Parent.OnJoo(aParam, bParam, cParam) 1533 | } 1534 | 1535 | func (_c *coconutJooCall) OnKoo(src string) *coconutKooCall { 1536 | return _c.Parent.OnKoo(src) 1537 | } 1538 | 1539 | func (_c *coconutJooCall) OnLoo(st string, values []int) *coconutLooCall { 1540 | return _c.Parent.OnLoo(st, values...) 1541 | } 1542 | 1543 | func (_c *coconutJooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 1544 | return _c.Parent.OnMoo(fn) 1545 | } 1546 | 1547 | func (_c *coconutJooCall) OnToo(src string) *coconutTooCall { 1548 | return _c.Parent.OnToo(src) 1549 | } 1550 | 1551 | func (_c *coconutJooCall) OnVoo(src *module.Version) *coconutVooCall { 1552 | return _c.Parent.OnVoo(src) 1553 | } 1554 | 1555 | func (_c *coconutJooCall) OnYoo(st string) *coconutYooCall { 1556 | return _c.Parent.OnYoo(st) 1557 | } 1558 | 1559 | func (_c *coconutJooCall) OnZoo(st interface{}) *coconutZooCall { 1560 | return _c.Parent.OnZoo(st) 1561 | } 1562 | 1563 | func (_c *coconutJooCall) OnBooRaw(src interface{}) *coconutBooCall { 1564 | return _c.Parent.OnBooRaw(src) 1565 | } 1566 | 1567 | func (_c *coconutJooCall) OnDooRaw(src interface{}) *coconutDooCall { 1568 | return _c.Parent.OnDooRaw(src) 1569 | } 1570 | 1571 | func (_c *coconutJooCall) OnFooRaw(st interface{}) *coconutFooCall { 1572 | return _c.Parent.OnFooRaw(st) 1573 | } 1574 | 1575 | func (_c *coconutJooCall) OnGooRaw(st interface{}) *coconutGooCall { 1576 | return _c.Parent.OnGooRaw(st) 1577 | } 1578 | 1579 | func (_c *coconutJooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 1580 | return _c.Parent.OnHooRaw(aParam, bParam, cParam) 1581 | } 1582 | 1583 | func (_c *coconutJooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 1584 | return _c.Parent.OnJooRaw(aParam, bParam, cParam) 1585 | } 1586 | 1587 | func (_c *coconutJooCall) OnKooRaw(src interface{}) *coconutKooCall { 1588 | return _c.Parent.OnKooRaw(src) 1589 | } 1590 | 1591 | func (_c *coconutJooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 1592 | return _c.Parent.OnLooRaw(st, values) 1593 | } 1594 | 1595 | func (_c *coconutJooCall) OnMooRaw(fn interface{}) *coconutMooCall { 1596 | return _c.Parent.OnMooRaw(fn) 1597 | } 1598 | 1599 | func (_c *coconutJooCall) OnTooRaw(src interface{}) *coconutTooCall { 1600 | return _c.Parent.OnTooRaw(src) 1601 | } 1602 | 1603 | func (_c *coconutJooCall) OnVooRaw(src interface{}) *coconutVooCall { 1604 | return _c.Parent.OnVooRaw(src) 1605 | } 1606 | 1607 | func (_c *coconutJooCall) OnYooRaw(st interface{}) *coconutYooCall { 1608 | return _c.Parent.OnYooRaw(st) 1609 | } 1610 | 1611 | func (_c *coconutJooCall) OnZooRaw(st interface{}) *coconutZooCall { 1612 | return _c.Parent.OnZooRaw(st) 1613 | } 1614 | 1615 | func (_m *coconutMock) Koo(src string) string { 1616 | _ret := _m.Called(src) 1617 | 1618 | if _rf, ok := _ret.Get(0).(func(string) string); ok { 1619 | return _rf(src) 1620 | } 1621 | 1622 | dst := _ret.String(0) 1623 | 1624 | return dst 1625 | } 1626 | 1627 | func (_m *coconutMock) OnKoo(src string) *coconutKooCall { 1628 | return &coconutKooCall{Call: _m.Mock.On("Koo", src), Parent: _m} 1629 | } 1630 | 1631 | func (_m *coconutMock) OnKooRaw(src interface{}) *coconutKooCall { 1632 | return &coconutKooCall{Call: _m.Mock.On("Koo", src), Parent: _m} 1633 | } 1634 | 1635 | type coconutKooCall struct { 1636 | *mock.Call 1637 | Parent *coconutMock 1638 | } 1639 | 1640 | func (_c *coconutKooCall) Panic(msg string) *coconutKooCall { 1641 | _c.Call = _c.Call.Panic(msg) 1642 | return _c 1643 | } 1644 | 1645 | func (_c *coconutKooCall) Once() *coconutKooCall { 1646 | _c.Call = _c.Call.Once() 1647 | return _c 1648 | } 1649 | 1650 | func (_c *coconutKooCall) Twice() *coconutKooCall { 1651 | _c.Call = _c.Call.Twice() 1652 | return _c 1653 | } 1654 | 1655 | func (_c *coconutKooCall) Times(i int) *coconutKooCall { 1656 | _c.Call = _c.Call.Times(i) 1657 | return _c 1658 | } 1659 | 1660 | func (_c *coconutKooCall) WaitUntil(w <-chan time.Time) *coconutKooCall { 1661 | _c.Call = _c.Call.WaitUntil(w) 1662 | return _c 1663 | } 1664 | 1665 | func (_c *coconutKooCall) After(d time.Duration) *coconutKooCall { 1666 | _c.Call = _c.Call.After(d) 1667 | return _c 1668 | } 1669 | 1670 | func (_c *coconutKooCall) Run(fn func(args mock.Arguments)) *coconutKooCall { 1671 | _c.Call = _c.Call.Run(fn) 1672 | return _c 1673 | } 1674 | 1675 | func (_c *coconutKooCall) Maybe() *coconutKooCall { 1676 | _c.Call = _c.Call.Maybe() 1677 | return _c 1678 | } 1679 | 1680 | func (_c *coconutKooCall) TypedReturns(a string) *coconutKooCall { 1681 | _c.Call = _c.Return(a) 1682 | return _c 1683 | } 1684 | 1685 | func (_c *coconutKooCall) ReturnsFn(fn func(string) string) *coconutKooCall { 1686 | _c.Call = _c.Return(fn) 1687 | return _c 1688 | } 1689 | 1690 | func (_c *coconutKooCall) TypedRun(fn func(string)) *coconutKooCall { 1691 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 1692 | _src := args.String(0) 1693 | fn(_src) 1694 | }) 1695 | return _c 1696 | } 1697 | 1698 | func (_c *coconutKooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { 1699 | return _c.Parent.OnBoo(src) 1700 | } 1701 | 1702 | func (_c *coconutKooCall) OnDoo(src time.Duration) *coconutDooCall { 1703 | return _c.Parent.OnDoo(src) 1704 | } 1705 | 1706 | func (_c *coconutKooCall) OnFoo(st Strawberry) *coconutFooCall { 1707 | return _c.Parent.OnFoo(st) 1708 | } 1709 | 1710 | func (_c *coconutKooCall) OnGoo(st string) *coconutGooCall { 1711 | return _c.Parent.OnGoo(st) 1712 | } 1713 | 1714 | func (_c *coconutKooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 1715 | return _c.Parent.OnHoo(aParam, bParam, cParam) 1716 | } 1717 | 1718 | func (_c *coconutKooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 1719 | return _c.Parent.OnJoo(aParam, bParam, cParam) 1720 | } 1721 | 1722 | func (_c *coconutKooCall) OnKoo(src string) *coconutKooCall { 1723 | return _c.Parent.OnKoo(src) 1724 | } 1725 | 1726 | func (_c *coconutKooCall) OnLoo(st string, values []int) *coconutLooCall { 1727 | return _c.Parent.OnLoo(st, values...) 1728 | } 1729 | 1730 | func (_c *coconutKooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 1731 | return _c.Parent.OnMoo(fn) 1732 | } 1733 | 1734 | func (_c *coconutKooCall) OnToo(src string) *coconutTooCall { 1735 | return _c.Parent.OnToo(src) 1736 | } 1737 | 1738 | func (_c *coconutKooCall) OnVoo(src *module.Version) *coconutVooCall { 1739 | return _c.Parent.OnVoo(src) 1740 | } 1741 | 1742 | func (_c *coconutKooCall) OnYoo(st string) *coconutYooCall { 1743 | return _c.Parent.OnYoo(st) 1744 | } 1745 | 1746 | func (_c *coconutKooCall) OnZoo(st interface{}) *coconutZooCall { 1747 | return _c.Parent.OnZoo(st) 1748 | } 1749 | 1750 | func (_c *coconutKooCall) OnBooRaw(src interface{}) *coconutBooCall { 1751 | return _c.Parent.OnBooRaw(src) 1752 | } 1753 | 1754 | func (_c *coconutKooCall) OnDooRaw(src interface{}) *coconutDooCall { 1755 | return _c.Parent.OnDooRaw(src) 1756 | } 1757 | 1758 | func (_c *coconutKooCall) OnFooRaw(st interface{}) *coconutFooCall { 1759 | return _c.Parent.OnFooRaw(st) 1760 | } 1761 | 1762 | func (_c *coconutKooCall) OnGooRaw(st interface{}) *coconutGooCall { 1763 | return _c.Parent.OnGooRaw(st) 1764 | } 1765 | 1766 | func (_c *coconutKooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 1767 | return _c.Parent.OnHooRaw(aParam, bParam, cParam) 1768 | } 1769 | 1770 | func (_c *coconutKooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 1771 | return _c.Parent.OnJooRaw(aParam, bParam, cParam) 1772 | } 1773 | 1774 | func (_c *coconutKooCall) OnKooRaw(src interface{}) *coconutKooCall { 1775 | return _c.Parent.OnKooRaw(src) 1776 | } 1777 | 1778 | func (_c *coconutKooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 1779 | return _c.Parent.OnLooRaw(st, values) 1780 | } 1781 | 1782 | func (_c *coconutKooCall) OnMooRaw(fn interface{}) *coconutMooCall { 1783 | return _c.Parent.OnMooRaw(fn) 1784 | } 1785 | 1786 | func (_c *coconutKooCall) OnTooRaw(src interface{}) *coconutTooCall { 1787 | return _c.Parent.OnTooRaw(src) 1788 | } 1789 | 1790 | func (_c *coconutKooCall) OnVooRaw(src interface{}) *coconutVooCall { 1791 | return _c.Parent.OnVooRaw(src) 1792 | } 1793 | 1794 | func (_c *coconutKooCall) OnYooRaw(st interface{}) *coconutYooCall { 1795 | return _c.Parent.OnYooRaw(st) 1796 | } 1797 | 1798 | func (_c *coconutKooCall) OnZooRaw(st interface{}) *coconutZooCall { 1799 | return _c.Parent.OnZooRaw(st) 1800 | } 1801 | 1802 | func (_m *coconutMock) Loo(st string, values ...int) string { 1803 | _ret := _m.Called(st, values) 1804 | 1805 | if _rf, ok := _ret.Get(0).(func(string, ...int) string); ok { 1806 | return _rf(st, values...) 1807 | } 1808 | 1809 | _ra0 := _ret.String(0) 1810 | 1811 | return _ra0 1812 | } 1813 | 1814 | func (_m *coconutMock) OnLoo(st string, values ...int) *coconutLooCall { 1815 | return &coconutLooCall{Call: _m.Mock.On("Loo", st, values), Parent: _m} 1816 | } 1817 | 1818 | func (_m *coconutMock) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 1819 | return &coconutLooCall{Call: _m.Mock.On("Loo", st, values), Parent: _m} 1820 | } 1821 | 1822 | type coconutLooCall struct { 1823 | *mock.Call 1824 | Parent *coconutMock 1825 | } 1826 | 1827 | func (_c *coconutLooCall) Panic(msg string) *coconutLooCall { 1828 | _c.Call = _c.Call.Panic(msg) 1829 | return _c 1830 | } 1831 | 1832 | func (_c *coconutLooCall) Once() *coconutLooCall { 1833 | _c.Call = _c.Call.Once() 1834 | return _c 1835 | } 1836 | 1837 | func (_c *coconutLooCall) Twice() *coconutLooCall { 1838 | _c.Call = _c.Call.Twice() 1839 | return _c 1840 | } 1841 | 1842 | func (_c *coconutLooCall) Times(i int) *coconutLooCall { 1843 | _c.Call = _c.Call.Times(i) 1844 | return _c 1845 | } 1846 | 1847 | func (_c *coconutLooCall) WaitUntil(w <-chan time.Time) *coconutLooCall { 1848 | _c.Call = _c.Call.WaitUntil(w) 1849 | return _c 1850 | } 1851 | 1852 | func (_c *coconutLooCall) After(d time.Duration) *coconutLooCall { 1853 | _c.Call = _c.Call.After(d) 1854 | return _c 1855 | } 1856 | 1857 | func (_c *coconutLooCall) Run(fn func(args mock.Arguments)) *coconutLooCall { 1858 | _c.Call = _c.Call.Run(fn) 1859 | return _c 1860 | } 1861 | 1862 | func (_c *coconutLooCall) Maybe() *coconutLooCall { 1863 | _c.Call = _c.Call.Maybe() 1864 | return _c 1865 | } 1866 | 1867 | func (_c *coconutLooCall) TypedReturns(a string) *coconutLooCall { 1868 | _c.Call = _c.Return(a) 1869 | return _c 1870 | } 1871 | 1872 | func (_c *coconutLooCall) ReturnsFn(fn func(string, ...int) string) *coconutLooCall { 1873 | _c.Call = _c.Return(fn) 1874 | return _c 1875 | } 1876 | 1877 | func (_c *coconutLooCall) TypedRun(fn func(string, ...int)) *coconutLooCall { 1878 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 1879 | _st := args.String(0) 1880 | _values, _ := args.Get(1).([]int) 1881 | fn(_st, _values...) 1882 | }) 1883 | return _c 1884 | } 1885 | 1886 | func (_c *coconutLooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { 1887 | return _c.Parent.OnBoo(src) 1888 | } 1889 | 1890 | func (_c *coconutLooCall) OnDoo(src time.Duration) *coconutDooCall { 1891 | return _c.Parent.OnDoo(src) 1892 | } 1893 | 1894 | func (_c *coconutLooCall) OnFoo(st Strawberry) *coconutFooCall { 1895 | return _c.Parent.OnFoo(st) 1896 | } 1897 | 1898 | func (_c *coconutLooCall) OnGoo(st string) *coconutGooCall { 1899 | return _c.Parent.OnGoo(st) 1900 | } 1901 | 1902 | func (_c *coconutLooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 1903 | return _c.Parent.OnHoo(aParam, bParam, cParam) 1904 | } 1905 | 1906 | func (_c *coconutLooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 1907 | return _c.Parent.OnJoo(aParam, bParam, cParam) 1908 | } 1909 | 1910 | func (_c *coconutLooCall) OnKoo(src string) *coconutKooCall { 1911 | return _c.Parent.OnKoo(src) 1912 | } 1913 | 1914 | func (_c *coconutLooCall) OnLoo(st string, values ...int) *coconutLooCall { 1915 | return _c.Parent.OnLoo(st, values...) 1916 | } 1917 | 1918 | func (_c *coconutLooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 1919 | return _c.Parent.OnMoo(fn) 1920 | } 1921 | 1922 | func (_c *coconutLooCall) OnToo(src string) *coconutTooCall { 1923 | return _c.Parent.OnToo(src) 1924 | } 1925 | 1926 | func (_c *coconutLooCall) OnVoo(src *module.Version) *coconutVooCall { 1927 | return _c.Parent.OnVoo(src) 1928 | } 1929 | 1930 | func (_c *coconutLooCall) OnYoo(st string) *coconutYooCall { 1931 | return _c.Parent.OnYoo(st) 1932 | } 1933 | 1934 | func (_c *coconutLooCall) OnZoo(st interface{}) *coconutZooCall { 1935 | return _c.Parent.OnZoo(st) 1936 | } 1937 | 1938 | func (_c *coconutLooCall) OnBooRaw(src interface{}) *coconutBooCall { 1939 | return _c.Parent.OnBooRaw(src) 1940 | } 1941 | 1942 | func (_c *coconutLooCall) OnDooRaw(src interface{}) *coconutDooCall { 1943 | return _c.Parent.OnDooRaw(src) 1944 | } 1945 | 1946 | func (_c *coconutLooCall) OnFooRaw(st interface{}) *coconutFooCall { 1947 | return _c.Parent.OnFooRaw(st) 1948 | } 1949 | 1950 | func (_c *coconutLooCall) OnGooRaw(st interface{}) *coconutGooCall { 1951 | return _c.Parent.OnGooRaw(st) 1952 | } 1953 | 1954 | func (_c *coconutLooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 1955 | return _c.Parent.OnHooRaw(aParam, bParam, cParam) 1956 | } 1957 | 1958 | func (_c *coconutLooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 1959 | return _c.Parent.OnJooRaw(aParam, bParam, cParam) 1960 | } 1961 | 1962 | func (_c *coconutLooCall) OnKooRaw(src interface{}) *coconutKooCall { 1963 | return _c.Parent.OnKooRaw(src) 1964 | } 1965 | 1966 | func (_c *coconutLooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 1967 | return _c.Parent.OnLooRaw(st, values) 1968 | } 1969 | 1970 | func (_c *coconutLooCall) OnMooRaw(fn interface{}) *coconutMooCall { 1971 | return _c.Parent.OnMooRaw(fn) 1972 | } 1973 | 1974 | func (_c *coconutLooCall) OnTooRaw(src interface{}) *coconutTooCall { 1975 | return _c.Parent.OnTooRaw(src) 1976 | } 1977 | 1978 | func (_c *coconutLooCall) OnVooRaw(src interface{}) *coconutVooCall { 1979 | return _c.Parent.OnVooRaw(src) 1980 | } 1981 | 1982 | func (_c *coconutLooCall) OnYooRaw(st interface{}) *coconutYooCall { 1983 | return _c.Parent.OnYooRaw(st) 1984 | } 1985 | 1986 | func (_c *coconutLooCall) OnZooRaw(st interface{}) *coconutZooCall { 1987 | return _c.Parent.OnZooRaw(st) 1988 | } 1989 | 1990 | func (_m *coconutMock) Moo(fn func(Strawberry, Strawberry) Pineapple) string { 1991 | _ret := _m.Called(fn) 1992 | 1993 | if _rf, ok := _ret.Get(0).(func(func(Strawberry, Strawberry) Pineapple) string); ok { 1994 | return _rf(fn) 1995 | } 1996 | 1997 | _ra0 := _ret.String(0) 1998 | 1999 | return _ra0 2000 | } 2001 | 2002 | func (_m *coconutMock) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 2003 | return &coconutMooCall{Call: _m.Mock.On("Moo", mock.Anything), Parent: _m} 2004 | } 2005 | 2006 | func (_m *coconutMock) OnMooRaw(fn interface{}) *coconutMooCall { 2007 | return &coconutMooCall{Call: _m.Mock.On("Moo", mock.Anything), Parent: _m} 2008 | } 2009 | 2010 | type coconutMooCall struct { 2011 | *mock.Call 2012 | Parent *coconutMock 2013 | } 2014 | 2015 | func (_c *coconutMooCall) Panic(msg string) *coconutMooCall { 2016 | _c.Call = _c.Call.Panic(msg) 2017 | return _c 2018 | } 2019 | 2020 | func (_c *coconutMooCall) Once() *coconutMooCall { 2021 | _c.Call = _c.Call.Once() 2022 | return _c 2023 | } 2024 | 2025 | func (_c *coconutMooCall) Twice() *coconutMooCall { 2026 | _c.Call = _c.Call.Twice() 2027 | return _c 2028 | } 2029 | 2030 | func (_c *coconutMooCall) Times(i int) *coconutMooCall { 2031 | _c.Call = _c.Call.Times(i) 2032 | return _c 2033 | } 2034 | 2035 | func (_c *coconutMooCall) WaitUntil(w <-chan time.Time) *coconutMooCall { 2036 | _c.Call = _c.Call.WaitUntil(w) 2037 | return _c 2038 | } 2039 | 2040 | func (_c *coconutMooCall) After(d time.Duration) *coconutMooCall { 2041 | _c.Call = _c.Call.After(d) 2042 | return _c 2043 | } 2044 | 2045 | func (_c *coconutMooCall) Run(fn func(args mock.Arguments)) *coconutMooCall { 2046 | _c.Call = _c.Call.Run(fn) 2047 | return _c 2048 | } 2049 | 2050 | func (_c *coconutMooCall) Maybe() *coconutMooCall { 2051 | _c.Call = _c.Call.Maybe() 2052 | return _c 2053 | } 2054 | 2055 | func (_c *coconutMooCall) TypedReturns(a string) *coconutMooCall { 2056 | _c.Call = _c.Return(a) 2057 | return _c 2058 | } 2059 | 2060 | func (_c *coconutMooCall) ReturnsFn(fn func(func(Strawberry, Strawberry) Pineapple) string) *coconutMooCall { 2061 | _c.Call = _c.Return(fn) 2062 | return _c 2063 | } 2064 | 2065 | func (_c *coconutMooCall) TypedRun(fn func(func(Strawberry, Strawberry) Pineapple)) *coconutMooCall { 2066 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 2067 | _fn, _ := args.Get(0).(func(Strawberry, Strawberry) Pineapple) 2068 | fn(_fn) 2069 | }) 2070 | return _c 2071 | } 2072 | 2073 | func (_c *coconutMooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { 2074 | return _c.Parent.OnBoo(src) 2075 | } 2076 | 2077 | func (_c *coconutMooCall) OnDoo(src time.Duration) *coconutDooCall { 2078 | return _c.Parent.OnDoo(src) 2079 | } 2080 | 2081 | func (_c *coconutMooCall) OnFoo(st Strawberry) *coconutFooCall { 2082 | return _c.Parent.OnFoo(st) 2083 | } 2084 | 2085 | func (_c *coconutMooCall) OnGoo(st string) *coconutGooCall { 2086 | return _c.Parent.OnGoo(st) 2087 | } 2088 | 2089 | func (_c *coconutMooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 2090 | return _c.Parent.OnHoo(aParam, bParam, cParam) 2091 | } 2092 | 2093 | func (_c *coconutMooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 2094 | return _c.Parent.OnJoo(aParam, bParam, cParam) 2095 | } 2096 | 2097 | func (_c *coconutMooCall) OnKoo(src string) *coconutKooCall { 2098 | return _c.Parent.OnKoo(src) 2099 | } 2100 | 2101 | func (_c *coconutMooCall) OnLoo(st string, values []int) *coconutLooCall { 2102 | return _c.Parent.OnLoo(st, values...) 2103 | } 2104 | 2105 | func (_c *coconutMooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 2106 | return _c.Parent.OnMoo(fn) 2107 | } 2108 | 2109 | func (_c *coconutMooCall) OnToo(src string) *coconutTooCall { 2110 | return _c.Parent.OnToo(src) 2111 | } 2112 | 2113 | func (_c *coconutMooCall) OnVoo(src *module.Version) *coconutVooCall { 2114 | return _c.Parent.OnVoo(src) 2115 | } 2116 | 2117 | func (_c *coconutMooCall) OnYoo(st string) *coconutYooCall { 2118 | return _c.Parent.OnYoo(st) 2119 | } 2120 | 2121 | func (_c *coconutMooCall) OnZoo(st interface{}) *coconutZooCall { 2122 | return _c.Parent.OnZoo(st) 2123 | } 2124 | 2125 | func (_c *coconutMooCall) OnBooRaw(src interface{}) *coconutBooCall { 2126 | return _c.Parent.OnBooRaw(src) 2127 | } 2128 | 2129 | func (_c *coconutMooCall) OnDooRaw(src interface{}) *coconutDooCall { 2130 | return _c.Parent.OnDooRaw(src) 2131 | } 2132 | 2133 | func (_c *coconutMooCall) OnFooRaw(st interface{}) *coconutFooCall { 2134 | return _c.Parent.OnFooRaw(st) 2135 | } 2136 | 2137 | func (_c *coconutMooCall) OnGooRaw(st interface{}) *coconutGooCall { 2138 | return _c.Parent.OnGooRaw(st) 2139 | } 2140 | 2141 | func (_c *coconutMooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 2142 | return _c.Parent.OnHooRaw(aParam, bParam, cParam) 2143 | } 2144 | 2145 | func (_c *coconutMooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 2146 | return _c.Parent.OnJooRaw(aParam, bParam, cParam) 2147 | } 2148 | 2149 | func (_c *coconutMooCall) OnKooRaw(src interface{}) *coconutKooCall { 2150 | return _c.Parent.OnKooRaw(src) 2151 | } 2152 | 2153 | func (_c *coconutMooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 2154 | return _c.Parent.OnLooRaw(st, values) 2155 | } 2156 | 2157 | func (_c *coconutMooCall) OnMooRaw(fn interface{}) *coconutMooCall { 2158 | return _c.Parent.OnMooRaw(fn) 2159 | } 2160 | 2161 | func (_c *coconutMooCall) OnTooRaw(src interface{}) *coconutTooCall { 2162 | return _c.Parent.OnTooRaw(src) 2163 | } 2164 | 2165 | func (_c *coconutMooCall) OnVooRaw(src interface{}) *coconutVooCall { 2166 | return _c.Parent.OnVooRaw(src) 2167 | } 2168 | 2169 | func (_c *coconutMooCall) OnYooRaw(st interface{}) *coconutYooCall { 2170 | return _c.Parent.OnYooRaw(st) 2171 | } 2172 | 2173 | func (_c *coconutMooCall) OnZooRaw(st interface{}) *coconutZooCall { 2174 | return _c.Parent.OnZooRaw(st) 2175 | } 2176 | 2177 | func (_m *coconutMock) Too(src string) time.Duration { 2178 | _ret := _m.Called(src) 2179 | 2180 | if _rf, ok := _ret.Get(0).(func(string) time.Duration); ok { 2181 | return _rf(src) 2182 | } 2183 | 2184 | _ra0, _ := _ret.Get(0).(time.Duration) 2185 | 2186 | return _ra0 2187 | } 2188 | 2189 | func (_m *coconutMock) OnToo(src string) *coconutTooCall { 2190 | return &coconutTooCall{Call: _m.Mock.On("Too", src), Parent: _m} 2191 | } 2192 | 2193 | func (_m *coconutMock) OnTooRaw(src interface{}) *coconutTooCall { 2194 | return &coconutTooCall{Call: _m.Mock.On("Too", src), Parent: _m} 2195 | } 2196 | 2197 | type coconutTooCall struct { 2198 | *mock.Call 2199 | Parent *coconutMock 2200 | } 2201 | 2202 | func (_c *coconutTooCall) Panic(msg string) *coconutTooCall { 2203 | _c.Call = _c.Call.Panic(msg) 2204 | return _c 2205 | } 2206 | 2207 | func (_c *coconutTooCall) Once() *coconutTooCall { 2208 | _c.Call = _c.Call.Once() 2209 | return _c 2210 | } 2211 | 2212 | func (_c *coconutTooCall) Twice() *coconutTooCall { 2213 | _c.Call = _c.Call.Twice() 2214 | return _c 2215 | } 2216 | 2217 | func (_c *coconutTooCall) Times(i int) *coconutTooCall { 2218 | _c.Call = _c.Call.Times(i) 2219 | return _c 2220 | } 2221 | 2222 | func (_c *coconutTooCall) WaitUntil(w <-chan time.Time) *coconutTooCall { 2223 | _c.Call = _c.Call.WaitUntil(w) 2224 | return _c 2225 | } 2226 | 2227 | func (_c *coconutTooCall) After(d time.Duration) *coconutTooCall { 2228 | _c.Call = _c.Call.After(d) 2229 | return _c 2230 | } 2231 | 2232 | func (_c *coconutTooCall) Run(fn func(args mock.Arguments)) *coconutTooCall { 2233 | _c.Call = _c.Call.Run(fn) 2234 | return _c 2235 | } 2236 | 2237 | func (_c *coconutTooCall) Maybe() *coconutTooCall { 2238 | _c.Call = _c.Call.Maybe() 2239 | return _c 2240 | } 2241 | 2242 | func (_c *coconutTooCall) TypedReturns(a time.Duration) *coconutTooCall { 2243 | _c.Call = _c.Return(a) 2244 | return _c 2245 | } 2246 | 2247 | func (_c *coconutTooCall) ReturnsFn(fn func(string) time.Duration) *coconutTooCall { 2248 | _c.Call = _c.Return(fn) 2249 | return _c 2250 | } 2251 | 2252 | func (_c *coconutTooCall) TypedRun(fn func(string)) *coconutTooCall { 2253 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 2254 | _src := args.String(0) 2255 | fn(_src) 2256 | }) 2257 | return _c 2258 | } 2259 | 2260 | func (_c *coconutTooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { 2261 | return _c.Parent.OnBoo(src) 2262 | } 2263 | 2264 | func (_c *coconutTooCall) OnDoo(src time.Duration) *coconutDooCall { 2265 | return _c.Parent.OnDoo(src) 2266 | } 2267 | 2268 | func (_c *coconutTooCall) OnFoo(st Strawberry) *coconutFooCall { 2269 | return _c.Parent.OnFoo(st) 2270 | } 2271 | 2272 | func (_c *coconutTooCall) OnGoo(st string) *coconutGooCall { 2273 | return _c.Parent.OnGoo(st) 2274 | } 2275 | 2276 | func (_c *coconutTooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 2277 | return _c.Parent.OnHoo(aParam, bParam, cParam) 2278 | } 2279 | 2280 | func (_c *coconutTooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 2281 | return _c.Parent.OnJoo(aParam, bParam, cParam) 2282 | } 2283 | 2284 | func (_c *coconutTooCall) OnKoo(src string) *coconutKooCall { 2285 | return _c.Parent.OnKoo(src) 2286 | } 2287 | 2288 | func (_c *coconutTooCall) OnLoo(st string, values []int) *coconutLooCall { 2289 | return _c.Parent.OnLoo(st, values...) 2290 | } 2291 | 2292 | func (_c *coconutTooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 2293 | return _c.Parent.OnMoo(fn) 2294 | } 2295 | 2296 | func (_c *coconutTooCall) OnToo(src string) *coconutTooCall { 2297 | return _c.Parent.OnToo(src) 2298 | } 2299 | 2300 | func (_c *coconutTooCall) OnVoo(src *module.Version) *coconutVooCall { 2301 | return _c.Parent.OnVoo(src) 2302 | } 2303 | 2304 | func (_c *coconutTooCall) OnYoo(st string) *coconutYooCall { 2305 | return _c.Parent.OnYoo(st) 2306 | } 2307 | 2308 | func (_c *coconutTooCall) OnZoo(st interface{}) *coconutZooCall { 2309 | return _c.Parent.OnZoo(st) 2310 | } 2311 | 2312 | func (_c *coconutTooCall) OnBooRaw(src interface{}) *coconutBooCall { 2313 | return _c.Parent.OnBooRaw(src) 2314 | } 2315 | 2316 | func (_c *coconutTooCall) OnDooRaw(src interface{}) *coconutDooCall { 2317 | return _c.Parent.OnDooRaw(src) 2318 | } 2319 | 2320 | func (_c *coconutTooCall) OnFooRaw(st interface{}) *coconutFooCall { 2321 | return _c.Parent.OnFooRaw(st) 2322 | } 2323 | 2324 | func (_c *coconutTooCall) OnGooRaw(st interface{}) *coconutGooCall { 2325 | return _c.Parent.OnGooRaw(st) 2326 | } 2327 | 2328 | func (_c *coconutTooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 2329 | return _c.Parent.OnHooRaw(aParam, bParam, cParam) 2330 | } 2331 | 2332 | func (_c *coconutTooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 2333 | return _c.Parent.OnJooRaw(aParam, bParam, cParam) 2334 | } 2335 | 2336 | func (_c *coconutTooCall) OnKooRaw(src interface{}) *coconutKooCall { 2337 | return _c.Parent.OnKooRaw(src) 2338 | } 2339 | 2340 | func (_c *coconutTooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 2341 | return _c.Parent.OnLooRaw(st, values) 2342 | } 2343 | 2344 | func (_c *coconutTooCall) OnMooRaw(fn interface{}) *coconutMooCall { 2345 | return _c.Parent.OnMooRaw(fn) 2346 | } 2347 | 2348 | func (_c *coconutTooCall) OnTooRaw(src interface{}) *coconutTooCall { 2349 | return _c.Parent.OnTooRaw(src) 2350 | } 2351 | 2352 | func (_c *coconutTooCall) OnVooRaw(src interface{}) *coconutVooCall { 2353 | return _c.Parent.OnVooRaw(src) 2354 | } 2355 | 2356 | func (_c *coconutTooCall) OnYooRaw(st interface{}) *coconutYooCall { 2357 | return _c.Parent.OnYooRaw(st) 2358 | } 2359 | 2360 | func (_c *coconutTooCall) OnZooRaw(st interface{}) *coconutZooCall { 2361 | return _c.Parent.OnZooRaw(st) 2362 | } 2363 | 2364 | func (_m *coconutMock) Voo(src *module.Version) time.Duration { 2365 | _ret := _m.Called(src) 2366 | 2367 | if _rf, ok := _ret.Get(0).(func(*module.Version) time.Duration); ok { 2368 | return _rf(src) 2369 | } 2370 | 2371 | _ra0, _ := _ret.Get(0).(time.Duration) 2372 | 2373 | return _ra0 2374 | } 2375 | 2376 | func (_m *coconutMock) OnVoo(src *module.Version) *coconutVooCall { 2377 | return &coconutVooCall{Call: _m.Mock.On("Voo", src), Parent: _m} 2378 | } 2379 | 2380 | func (_m *coconutMock) OnVooRaw(src interface{}) *coconutVooCall { 2381 | return &coconutVooCall{Call: _m.Mock.On("Voo", src), Parent: _m} 2382 | } 2383 | 2384 | type coconutVooCall struct { 2385 | *mock.Call 2386 | Parent *coconutMock 2387 | } 2388 | 2389 | func (_c *coconutVooCall) Panic(msg string) *coconutVooCall { 2390 | _c.Call = _c.Call.Panic(msg) 2391 | return _c 2392 | } 2393 | 2394 | func (_c *coconutVooCall) Once() *coconutVooCall { 2395 | _c.Call = _c.Call.Once() 2396 | return _c 2397 | } 2398 | 2399 | func (_c *coconutVooCall) Twice() *coconutVooCall { 2400 | _c.Call = _c.Call.Twice() 2401 | return _c 2402 | } 2403 | 2404 | func (_c *coconutVooCall) Times(i int) *coconutVooCall { 2405 | _c.Call = _c.Call.Times(i) 2406 | return _c 2407 | } 2408 | 2409 | func (_c *coconutVooCall) WaitUntil(w <-chan time.Time) *coconutVooCall { 2410 | _c.Call = _c.Call.WaitUntil(w) 2411 | return _c 2412 | } 2413 | 2414 | func (_c *coconutVooCall) After(d time.Duration) *coconutVooCall { 2415 | _c.Call = _c.Call.After(d) 2416 | return _c 2417 | } 2418 | 2419 | func (_c *coconutVooCall) Run(fn func(args mock.Arguments)) *coconutVooCall { 2420 | _c.Call = _c.Call.Run(fn) 2421 | return _c 2422 | } 2423 | 2424 | func (_c *coconutVooCall) Maybe() *coconutVooCall { 2425 | _c.Call = _c.Call.Maybe() 2426 | return _c 2427 | } 2428 | 2429 | func (_c *coconutVooCall) TypedReturns(a time.Duration) *coconutVooCall { 2430 | _c.Call = _c.Return(a) 2431 | return _c 2432 | } 2433 | 2434 | func (_c *coconutVooCall) ReturnsFn(fn func(*module.Version) time.Duration) *coconutVooCall { 2435 | _c.Call = _c.Return(fn) 2436 | return _c 2437 | } 2438 | 2439 | func (_c *coconutVooCall) TypedRun(fn func(*module.Version)) *coconutVooCall { 2440 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 2441 | _src, _ := args.Get(0).(*module.Version) 2442 | fn(_src) 2443 | }) 2444 | return _c 2445 | } 2446 | 2447 | func (_c *coconutVooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { 2448 | return _c.Parent.OnBoo(src) 2449 | } 2450 | 2451 | func (_c *coconutVooCall) OnDoo(src time.Duration) *coconutDooCall { 2452 | return _c.Parent.OnDoo(src) 2453 | } 2454 | 2455 | func (_c *coconutVooCall) OnFoo(st Strawberry) *coconutFooCall { 2456 | return _c.Parent.OnFoo(st) 2457 | } 2458 | 2459 | func (_c *coconutVooCall) OnGoo(st string) *coconutGooCall { 2460 | return _c.Parent.OnGoo(st) 2461 | } 2462 | 2463 | func (_c *coconutVooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 2464 | return _c.Parent.OnHoo(aParam, bParam, cParam) 2465 | } 2466 | 2467 | func (_c *coconutVooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 2468 | return _c.Parent.OnJoo(aParam, bParam, cParam) 2469 | } 2470 | 2471 | func (_c *coconutVooCall) OnKoo(src string) *coconutKooCall { 2472 | return _c.Parent.OnKoo(src) 2473 | } 2474 | 2475 | func (_c *coconutVooCall) OnLoo(st string, values []int) *coconutLooCall { 2476 | return _c.Parent.OnLoo(st, values...) 2477 | } 2478 | 2479 | func (_c *coconutVooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 2480 | return _c.Parent.OnMoo(fn) 2481 | } 2482 | 2483 | func (_c *coconutVooCall) OnToo(src string) *coconutTooCall { 2484 | return _c.Parent.OnToo(src) 2485 | } 2486 | 2487 | func (_c *coconutVooCall) OnVoo(src *module.Version) *coconutVooCall { 2488 | return _c.Parent.OnVoo(src) 2489 | } 2490 | 2491 | func (_c *coconutVooCall) OnYoo(st string) *coconutYooCall { 2492 | return _c.Parent.OnYoo(st) 2493 | } 2494 | 2495 | func (_c *coconutVooCall) OnZoo(st interface{}) *coconutZooCall { 2496 | return _c.Parent.OnZoo(st) 2497 | } 2498 | 2499 | func (_c *coconutVooCall) OnBooRaw(src interface{}) *coconutBooCall { 2500 | return _c.Parent.OnBooRaw(src) 2501 | } 2502 | 2503 | func (_c *coconutVooCall) OnDooRaw(src interface{}) *coconutDooCall { 2504 | return _c.Parent.OnDooRaw(src) 2505 | } 2506 | 2507 | func (_c *coconutVooCall) OnFooRaw(st interface{}) *coconutFooCall { 2508 | return _c.Parent.OnFooRaw(st) 2509 | } 2510 | 2511 | func (_c *coconutVooCall) OnGooRaw(st interface{}) *coconutGooCall { 2512 | return _c.Parent.OnGooRaw(st) 2513 | } 2514 | 2515 | func (_c *coconutVooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 2516 | return _c.Parent.OnHooRaw(aParam, bParam, cParam) 2517 | } 2518 | 2519 | func (_c *coconutVooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 2520 | return _c.Parent.OnJooRaw(aParam, bParam, cParam) 2521 | } 2522 | 2523 | func (_c *coconutVooCall) OnKooRaw(src interface{}) *coconutKooCall { 2524 | return _c.Parent.OnKooRaw(src) 2525 | } 2526 | 2527 | func (_c *coconutVooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 2528 | return _c.Parent.OnLooRaw(st, values) 2529 | } 2530 | 2531 | func (_c *coconutVooCall) OnMooRaw(fn interface{}) *coconutMooCall { 2532 | return _c.Parent.OnMooRaw(fn) 2533 | } 2534 | 2535 | func (_c *coconutVooCall) OnTooRaw(src interface{}) *coconutTooCall { 2536 | return _c.Parent.OnTooRaw(src) 2537 | } 2538 | 2539 | func (_c *coconutVooCall) OnVooRaw(src interface{}) *coconutVooCall { 2540 | return _c.Parent.OnVooRaw(src) 2541 | } 2542 | 2543 | func (_c *coconutVooCall) OnYooRaw(st interface{}) *coconutYooCall { 2544 | return _c.Parent.OnYooRaw(st) 2545 | } 2546 | 2547 | func (_c *coconutVooCall) OnZooRaw(st interface{}) *coconutZooCall { 2548 | return _c.Parent.OnZooRaw(st) 2549 | } 2550 | 2551 | func (_m *coconutMock) Yoo(st string) interface{} { 2552 | _ret := _m.Called(st) 2553 | 2554 | if _rf, ok := _ret.Get(0).(func(string) interface{}); ok { 2555 | return _rf(st) 2556 | } 2557 | 2558 | _ra0, _ := _ret.Get(0).(interface{}) 2559 | 2560 | return _ra0 2561 | } 2562 | 2563 | func (_m *coconutMock) OnYoo(st string) *coconutYooCall { 2564 | return &coconutYooCall{Call: _m.Mock.On("Yoo", st), Parent: _m} 2565 | } 2566 | 2567 | func (_m *coconutMock) OnYooRaw(st interface{}) *coconutYooCall { 2568 | return &coconutYooCall{Call: _m.Mock.On("Yoo", st), Parent: _m} 2569 | } 2570 | 2571 | type coconutYooCall struct { 2572 | *mock.Call 2573 | Parent *coconutMock 2574 | } 2575 | 2576 | func (_c *coconutYooCall) Panic(msg string) *coconutYooCall { 2577 | _c.Call = _c.Call.Panic(msg) 2578 | return _c 2579 | } 2580 | 2581 | func (_c *coconutYooCall) Once() *coconutYooCall { 2582 | _c.Call = _c.Call.Once() 2583 | return _c 2584 | } 2585 | 2586 | func (_c *coconutYooCall) Twice() *coconutYooCall { 2587 | _c.Call = _c.Call.Twice() 2588 | return _c 2589 | } 2590 | 2591 | func (_c *coconutYooCall) Times(i int) *coconutYooCall { 2592 | _c.Call = _c.Call.Times(i) 2593 | return _c 2594 | } 2595 | 2596 | func (_c *coconutYooCall) WaitUntil(w <-chan time.Time) *coconutYooCall { 2597 | _c.Call = _c.Call.WaitUntil(w) 2598 | return _c 2599 | } 2600 | 2601 | func (_c *coconutYooCall) After(d time.Duration) *coconutYooCall { 2602 | _c.Call = _c.Call.After(d) 2603 | return _c 2604 | } 2605 | 2606 | func (_c *coconutYooCall) Run(fn func(args mock.Arguments)) *coconutYooCall { 2607 | _c.Call = _c.Call.Run(fn) 2608 | return _c 2609 | } 2610 | 2611 | func (_c *coconutYooCall) Maybe() *coconutYooCall { 2612 | _c.Call = _c.Call.Maybe() 2613 | return _c 2614 | } 2615 | 2616 | func (_c *coconutYooCall) TypedReturns(a interface{}) *coconutYooCall { 2617 | _c.Call = _c.Return(a) 2618 | return _c 2619 | } 2620 | 2621 | func (_c *coconutYooCall) ReturnsFn(fn func(string) interface{}) *coconutYooCall { 2622 | _c.Call = _c.Return(fn) 2623 | return _c 2624 | } 2625 | 2626 | func (_c *coconutYooCall) TypedRun(fn func(string)) *coconutYooCall { 2627 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 2628 | _st := args.String(0) 2629 | fn(_st) 2630 | }) 2631 | return _c 2632 | } 2633 | 2634 | func (_c *coconutYooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { 2635 | return _c.Parent.OnBoo(src) 2636 | } 2637 | 2638 | func (_c *coconutYooCall) OnDoo(src time.Duration) *coconutDooCall { 2639 | return _c.Parent.OnDoo(src) 2640 | } 2641 | 2642 | func (_c *coconutYooCall) OnFoo(st Strawberry) *coconutFooCall { 2643 | return _c.Parent.OnFoo(st) 2644 | } 2645 | 2646 | func (_c *coconutYooCall) OnGoo(st string) *coconutGooCall { 2647 | return _c.Parent.OnGoo(st) 2648 | } 2649 | 2650 | func (_c *coconutYooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 2651 | return _c.Parent.OnHoo(aParam, bParam, cParam) 2652 | } 2653 | 2654 | func (_c *coconutYooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 2655 | return _c.Parent.OnJoo(aParam, bParam, cParam) 2656 | } 2657 | 2658 | func (_c *coconutYooCall) OnKoo(src string) *coconutKooCall { 2659 | return _c.Parent.OnKoo(src) 2660 | } 2661 | 2662 | func (_c *coconutYooCall) OnLoo(st string, values []int) *coconutLooCall { 2663 | return _c.Parent.OnLoo(st, values...) 2664 | } 2665 | 2666 | func (_c *coconutYooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 2667 | return _c.Parent.OnMoo(fn) 2668 | } 2669 | 2670 | func (_c *coconutYooCall) OnToo(src string) *coconutTooCall { 2671 | return _c.Parent.OnToo(src) 2672 | } 2673 | 2674 | func (_c *coconutYooCall) OnVoo(src *module.Version) *coconutVooCall { 2675 | return _c.Parent.OnVoo(src) 2676 | } 2677 | 2678 | func (_c *coconutYooCall) OnYoo(st string) *coconutYooCall { 2679 | return _c.Parent.OnYoo(st) 2680 | } 2681 | 2682 | func (_c *coconutYooCall) OnZoo(st interface{}) *coconutZooCall { 2683 | return _c.Parent.OnZoo(st) 2684 | } 2685 | 2686 | func (_c *coconutYooCall) OnBooRaw(src interface{}) *coconutBooCall { 2687 | return _c.Parent.OnBooRaw(src) 2688 | } 2689 | 2690 | func (_c *coconutYooCall) OnDooRaw(src interface{}) *coconutDooCall { 2691 | return _c.Parent.OnDooRaw(src) 2692 | } 2693 | 2694 | func (_c *coconutYooCall) OnFooRaw(st interface{}) *coconutFooCall { 2695 | return _c.Parent.OnFooRaw(st) 2696 | } 2697 | 2698 | func (_c *coconutYooCall) OnGooRaw(st interface{}) *coconutGooCall { 2699 | return _c.Parent.OnGooRaw(st) 2700 | } 2701 | 2702 | func (_c *coconutYooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 2703 | return _c.Parent.OnHooRaw(aParam, bParam, cParam) 2704 | } 2705 | 2706 | func (_c *coconutYooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 2707 | return _c.Parent.OnJooRaw(aParam, bParam, cParam) 2708 | } 2709 | 2710 | func (_c *coconutYooCall) OnKooRaw(src interface{}) *coconutKooCall { 2711 | return _c.Parent.OnKooRaw(src) 2712 | } 2713 | 2714 | func (_c *coconutYooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 2715 | return _c.Parent.OnLooRaw(st, values) 2716 | } 2717 | 2718 | func (_c *coconutYooCall) OnMooRaw(fn interface{}) *coconutMooCall { 2719 | return _c.Parent.OnMooRaw(fn) 2720 | } 2721 | 2722 | func (_c *coconutYooCall) OnTooRaw(src interface{}) *coconutTooCall { 2723 | return _c.Parent.OnTooRaw(src) 2724 | } 2725 | 2726 | func (_c *coconutYooCall) OnVooRaw(src interface{}) *coconutVooCall { 2727 | return _c.Parent.OnVooRaw(src) 2728 | } 2729 | 2730 | func (_c *coconutYooCall) OnYooRaw(st interface{}) *coconutYooCall { 2731 | return _c.Parent.OnYooRaw(st) 2732 | } 2733 | 2734 | func (_c *coconutYooCall) OnZooRaw(st interface{}) *coconutZooCall { 2735 | return _c.Parent.OnZooRaw(st) 2736 | } 2737 | 2738 | func (_m *coconutMock) Zoo(st interface{}) string { 2739 | _ret := _m.Called(st) 2740 | 2741 | if _rf, ok := _ret.Get(0).(func(interface{}) string); ok { 2742 | return _rf(st) 2743 | } 2744 | 2745 | _ra0 := _ret.String(0) 2746 | 2747 | return _ra0 2748 | } 2749 | 2750 | func (_m *coconutMock) OnZoo(st interface{}) *coconutZooCall { 2751 | return &coconutZooCall{Call: _m.Mock.On("Zoo", st), Parent: _m} 2752 | } 2753 | 2754 | func (_m *coconutMock) OnZooRaw(st interface{}) *coconutZooCall { 2755 | return &coconutZooCall{Call: _m.Mock.On("Zoo", st), Parent: _m} 2756 | } 2757 | 2758 | type coconutZooCall struct { 2759 | *mock.Call 2760 | Parent *coconutMock 2761 | } 2762 | 2763 | func (_c *coconutZooCall) Panic(msg string) *coconutZooCall { 2764 | _c.Call = _c.Call.Panic(msg) 2765 | return _c 2766 | } 2767 | 2768 | func (_c *coconutZooCall) Once() *coconutZooCall { 2769 | _c.Call = _c.Call.Once() 2770 | return _c 2771 | } 2772 | 2773 | func (_c *coconutZooCall) Twice() *coconutZooCall { 2774 | _c.Call = _c.Call.Twice() 2775 | return _c 2776 | } 2777 | 2778 | func (_c *coconutZooCall) Times(i int) *coconutZooCall { 2779 | _c.Call = _c.Call.Times(i) 2780 | return _c 2781 | } 2782 | 2783 | func (_c *coconutZooCall) WaitUntil(w <-chan time.Time) *coconutZooCall { 2784 | _c.Call = _c.Call.WaitUntil(w) 2785 | return _c 2786 | } 2787 | 2788 | func (_c *coconutZooCall) After(d time.Duration) *coconutZooCall { 2789 | _c.Call = _c.Call.After(d) 2790 | return _c 2791 | } 2792 | 2793 | func (_c *coconutZooCall) Run(fn func(args mock.Arguments)) *coconutZooCall { 2794 | _c.Call = _c.Call.Run(fn) 2795 | return _c 2796 | } 2797 | 2798 | func (_c *coconutZooCall) Maybe() *coconutZooCall { 2799 | _c.Call = _c.Call.Maybe() 2800 | return _c 2801 | } 2802 | 2803 | func (_c *coconutZooCall) TypedReturns(a string) *coconutZooCall { 2804 | _c.Call = _c.Return(a) 2805 | return _c 2806 | } 2807 | 2808 | func (_c *coconutZooCall) ReturnsFn(fn func(interface{}) string) *coconutZooCall { 2809 | _c.Call = _c.Return(fn) 2810 | return _c 2811 | } 2812 | 2813 | func (_c *coconutZooCall) TypedRun(fn func(interface{})) *coconutZooCall { 2814 | _c.Call = _c.Call.Run(func(args mock.Arguments) { 2815 | _st, _ := args.Get(0).(interface{}) 2816 | fn(_st) 2817 | }) 2818 | return _c 2819 | } 2820 | 2821 | func (_c *coconutZooCall) OnBoo(src *bytes.Buffer) *coconutBooCall { 2822 | return _c.Parent.OnBoo(src) 2823 | } 2824 | 2825 | func (_c *coconutZooCall) OnDoo(src time.Duration) *coconutDooCall { 2826 | return _c.Parent.OnDoo(src) 2827 | } 2828 | 2829 | func (_c *coconutZooCall) OnFoo(st Strawberry) *coconutFooCall { 2830 | return _c.Parent.OnFoo(st) 2831 | } 2832 | 2833 | func (_c *coconutZooCall) OnGoo(st string) *coconutGooCall { 2834 | return _c.Parent.OnGoo(st) 2835 | } 2836 | 2837 | func (_c *coconutZooCall) OnHoo(aParam string, bParam int, cParam Water) *coconutHooCall { 2838 | return _c.Parent.OnHoo(aParam, bParam, cParam) 2839 | } 2840 | 2841 | func (_c *coconutZooCall) OnJoo(aParam string, bParam int, cParam Water) *coconutJooCall { 2842 | return _c.Parent.OnJoo(aParam, bParam, cParam) 2843 | } 2844 | 2845 | func (_c *coconutZooCall) OnKoo(src string) *coconutKooCall { 2846 | return _c.Parent.OnKoo(src) 2847 | } 2848 | 2849 | func (_c *coconutZooCall) OnLoo(st string, values []int) *coconutLooCall { 2850 | return _c.Parent.OnLoo(st, values...) 2851 | } 2852 | 2853 | func (_c *coconutZooCall) OnMoo(fn func(Strawberry, Strawberry) Pineapple) *coconutMooCall { 2854 | return _c.Parent.OnMoo(fn) 2855 | } 2856 | 2857 | func (_c *coconutZooCall) OnToo(src string) *coconutTooCall { 2858 | return _c.Parent.OnToo(src) 2859 | } 2860 | 2861 | func (_c *coconutZooCall) OnVoo(src *module.Version) *coconutVooCall { 2862 | return _c.Parent.OnVoo(src) 2863 | } 2864 | 2865 | func (_c *coconutZooCall) OnYoo(st string) *coconutYooCall { 2866 | return _c.Parent.OnYoo(st) 2867 | } 2868 | 2869 | func (_c *coconutZooCall) OnZoo(st interface{}) *coconutZooCall { 2870 | return _c.Parent.OnZoo(st) 2871 | } 2872 | 2873 | func (_c *coconutZooCall) OnBooRaw(src interface{}) *coconutBooCall { 2874 | return _c.Parent.OnBooRaw(src) 2875 | } 2876 | 2877 | func (_c *coconutZooCall) OnDooRaw(src interface{}) *coconutDooCall { 2878 | return _c.Parent.OnDooRaw(src) 2879 | } 2880 | 2881 | func (_c *coconutZooCall) OnFooRaw(st interface{}) *coconutFooCall { 2882 | return _c.Parent.OnFooRaw(st) 2883 | } 2884 | 2885 | func (_c *coconutZooCall) OnGooRaw(st interface{}) *coconutGooCall { 2886 | return _c.Parent.OnGooRaw(st) 2887 | } 2888 | 2889 | func (_c *coconutZooCall) OnHooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutHooCall { 2890 | return _c.Parent.OnHooRaw(aParam, bParam, cParam) 2891 | } 2892 | 2893 | func (_c *coconutZooCall) OnJooRaw(aParam interface{}, bParam interface{}, cParam interface{}) *coconutJooCall { 2894 | return _c.Parent.OnJooRaw(aParam, bParam, cParam) 2895 | } 2896 | 2897 | func (_c *coconutZooCall) OnKooRaw(src interface{}) *coconutKooCall { 2898 | return _c.Parent.OnKooRaw(src) 2899 | } 2900 | 2901 | func (_c *coconutZooCall) OnLooRaw(st interface{}, values interface{}) *coconutLooCall { 2902 | return _c.Parent.OnLooRaw(st, values) 2903 | } 2904 | 2905 | func (_c *coconutZooCall) OnMooRaw(fn interface{}) *coconutMooCall { 2906 | return _c.Parent.OnMooRaw(fn) 2907 | } 2908 | 2909 | func (_c *coconutZooCall) OnTooRaw(src interface{}) *coconutTooCall { 2910 | return _c.Parent.OnTooRaw(src) 2911 | } 2912 | 2913 | func (_c *coconutZooCall) OnVooRaw(src interface{}) *coconutVooCall { 2914 | return _c.Parent.OnVooRaw(src) 2915 | } 2916 | 2917 | func (_c *coconutZooCall) OnYooRaw(st interface{}) *coconutYooCall { 2918 | return _c.Parent.OnYooRaw(st) 2919 | } 2920 | 2921 | func (_c *coconutZooCall) OnZooRaw(st interface{}) *coconutZooCall { 2922 | return _c.Parent.OnZooRaw(st) 2923 | } 2924 | --------------------------------------------------------------------------------