diff --git a/mock/cmd/cmg/pkg/generate/_tests/conflicts/conflicts.go b/mock/cmd/cmg/pkg/generate/_tests/conflicts/conflicts.go new file mode 100644 index 00000000..c846c5ec --- /dev/null +++ b/mock/cmd/cmg/pkg/generate/_tests/conflicts/conflicts.go @@ -0,0 +1,7 @@ +package testing + +type ( + Conflicts interface { + Simple(c *Conflicts) *Conflicts + } +) diff --git a/mock/cmd/cmg/pkg/generate/_tests/conflicts/mocks/conflicts.go b/mock/cmd/cmg/pkg/generate/_tests/conflicts/mocks/conflicts.go new file mode 100644 index 00000000..565a1402 --- /dev/null +++ b/mock/cmd/cmg/pkg/generate/_tests/conflicts/mocks/conflicts.go @@ -0,0 +1,52 @@ +// Code generated by Clue Mock Generator TEST VERSION, DO NOT EDIT. +// +// Command: +// $ cmg gen example.com/c/d/conflicts + +package mocktesting + +import ( + "testing" + + "goa.design/clue/mock" + + testing1 "example.com/c/d/conflicts" +) + +type ( + Conflicts struct { + m *mock.Mock + t *testing.T + } + + ConflictsSimpleFunc func(c *testing1.Conflicts) *testing1.Conflicts +) + +func NewConflicts(t *testing.T) *Conflicts { + var ( + m = &Conflicts{mock.New(), t} + _ testing1.Conflicts = m + ) + return m +} + +func (m *Conflicts) AddSimple(f ConflictsSimpleFunc) { + m.m.Add("Simple", f) +} + +func (m *Conflicts) SetSimple(f ConflictsSimpleFunc) { + m.m.Set("Simple", f) +} + +func (m *Conflicts) Simple(c *testing1.Conflicts) *testing1.Conflicts { + if f := m.m.Next("Simple"); f != nil { + return f.(ConflictsSimpleFunc)(c) + } + m.t.Helper() + m.t.Error("unexpected Simple call") + return nil +} + +func (m *Conflicts) HasMore() bool { + return m.m.HasMore() +} diff --git a/mock/cmd/cmg/pkg/generate/mocks.go b/mock/cmd/cmg/pkg/generate/mocks.go index 32fbaa75..b2e04cd6 100644 --- a/mock/cmd/cmg/pkg/generate/mocks.go +++ b/mock/cmd/cmg/pkg/generate/mocks.go @@ -42,22 +42,20 @@ var ( func NewMocks(prefix string, p parse.Package, interfaces []parse.Interface, toolVersionFunc ToolVersionFunc) Mocks { var ( - m = &mocks{ - pkgName: prefix + p.Name(), - pkgPath: p.PkgPath(), - pkgImport: newImport(p.PkgPath(), p.Name()), - toolVersionFunc: toolVersionFunc, - } stdImports = importMap{"testing": newImport("testing")} extImports = importMap{"mock": newImport("goa.design/clue/mock")} intImports = make(importMap) modPath = p.ModPath() - typeNames = make(typeMap) - typeZeros = make(typeMap) + m = &mocks{ + pkgName: prefix + p.Name(), + pkgPath: p.PkgPath(), + pkgImport: addImport(newImport(p.PkgPath(), p.Name()), stdImports, extImports, intImports, modPath), + toolVersionFunc: toolVersionFunc, + } + typeNames = make(typeMap) + typeZeros = make(typeMap) ) - addImport(m.pkgImport, stdImports, extImports, intImports, modPath) - for _, i := range interfaces { m.interfaces = append(m.interfaces, newInterface(i, typeNames, typeZeros, stdImports, extImports, intImports, modPath)) } diff --git a/mock/cmd/cmg/pkg/generate/mocks.go.tmpl b/mock/cmd/cmg/pkg/generate/mocks.go.tmpl index 2728ec1f..fcde55d5 100644 --- a/mock/cmd/cmg/pkg/generate/mocks.go.tmpl +++ b/mock/cmd/cmg/pkg/generate/mocks.go.tmpl @@ -36,8 +36,8 @@ type ( {{ end }} func {{ .Constructor }}{{ .TypeParameters }}(t *testing.T) *{{ .Name }}{{ .TypeParameterVars }} { var ( - {{ .Var | printf ($import.PkgName | .ConstructorFmt) }} = &{{ .Name }}{{ .TypeParameterVars }}{mock.New(), t} - _ {{ $import.PkgName }}.{{ .Name }}{{ .TypeParameterVars }} = m + {{ .Var | printf ($import.AliasOrPkgName | .ConstructorFmt) }} = &{{ .Name }}{{ .TypeParameterVars }}{mock.New(), t} + _ {{ $import.AliasOrPkgName }}.{{ .Name }}{{ .TypeParameterVars }} = m ) return {{ .Var }} } diff --git a/mock/cmd/cmg/pkg/generate/mocks_test.go b/mock/cmd/cmg/pkg/generate/mocks_test.go index 1ff6b9dc..43cfc647 100644 --- a/mock/cmd/cmg/pkg/generate/mocks_test.go +++ b/mock/cmd/cmg/pkg/generate/mocks_test.go @@ -22,6 +22,11 @@ func TestMocks_Render(t *testing.T) { Pattern: "./extensive", ExpectedFiles: []string{"extensive.go"}, }, + { + Name: "conflicts", + Pattern: "./conflicts", + ExpectedFiles: []string{"conflicts.go"}, + }, } for _, tc := range cases { diff --git a/mock/cmd/cmg/pkg/version.go b/mock/cmd/cmg/pkg/version.go index 8140a7eb..3146f9dd 100644 --- a/mock/cmd/cmg/pkg/version.go +++ b/mock/cmd/cmg/pkg/version.go @@ -8,7 +8,7 @@ const ( // Major version number Major = 0 // Minor version number - Minor = 17 + Minor = 18 // Build number Build = 1 // Suffix - set to empty string in release tag commits.