diff --git a/README.md b/README.md index e6619fa..63e7f12 100644 --- a/README.md +++ b/README.md @@ -25,18 +25,19 @@ Depending on how you prefer to structure your code, you can either The following flags are defined by the binary. -| Name | Short Flag | Description | -| ------------------ | ---------- | ----------------------------------------------------------------------------------------------------------------- | +| Name | Short Flag | Description | +| ------------------ | ---------- | ----------- | | package | p | The name of the generated package. Is the name of target directory if dirname or filename is supplied by default. | -| prefix | | A prefix used in the name of each mock struct. Should be TitleCase by convention. | -| interfaces | i | A list of interfaces to generate given the import paths. | -| exclude | e | A list of interfaces to exclude from generation. | -| filename | o | The target output file. All mocks are written to this file. | -| dirname | d | The target output directory. Each mock will be written to a unique file. | -| force | f | Do not abort if a write to disk would overwrite an existing file. | -| disable-formatting | | Do not run goimports over the rendered files (enabled by default). | -| goimports | | Path to the goimports binary (uses goimports on your PATH by default). | -| for-test | | Append _test suffix to generated package names and file names. | +| prefix | | A prefix used in the name of each mock struct. Should be TitleCase by convention. | +| constructor-prefix | | A prefix used in the name of each mock constructor function (after the initial `New`/`NewStrict` prefixes). Should be TitleCase by convention. | +| interfaces | i | A list of interfaces to generate given the import paths. | +| exclude | e | A list of interfaces to exclude from generation. | +| filename | o | The target output file. All mocks are written to this file. | +| dirname | d | The target output directory. Each mock will be written to a unique file. | +| force | f | Do not abort if a write to disk would overwrite an existing file. | +| disable-formatting | | Do not run goimports over the rendered files (enabled by default). | +| goimports | | Path to the goimports binary (uses goimports on your PATH by default). | +| for-test | | Append _test suffix to generated package names and file names. | ## Testing with Mocks diff --git a/cmd/go-mockgen/args.go b/cmd/go-mockgen/args.go index da62b51..2afcc2a 100644 --- a/cmd/go-mockgen/args.go +++ b/cmd/go-mockgen/args.go @@ -31,6 +31,7 @@ func parseArgs() (*generation.Options, error) { app.Flag("filename", "The target output file. All mocks are written to this file.").Short('o').StringVar(&opts.OutputFilename) app.Flag("import-path", "The import path of the generated package. It will be inferred from the target directory by default.").StringVar(&opts.PkgName) app.Flag("prefix", "A prefix used in the name of each mock struct. Should be TitleCase by convention.").StringVar(&opts.Prefix) + app.Flag("constructor-prefix", "A prefix used in the name of each mock constructor function (after the initial `New`/`NewStrict` prefixes). Should be TitleCase by convention.").StringVar(&opts.ConstructorPrefix) app.Flag("force", "Do not abort if a write to disk would overwrite an existing file.").Short('f').BoolVar(&opts.Force) app.Flag("disable-formatting", "Do not run goimports over the rendered files.").BoolVar(&opts.DisableFormatting) app.Flag("goimports", "Path to the goimports binary.").Default("goimports").StringVar(&opts.GoImportsBinary) @@ -120,6 +121,10 @@ func validateOptions(opts *generation.Options) (bool, error) { return false, fmt.Errorf("prefix `%s` is illegal", opts.Prefix) } + if opts.ConstructorPrefix != "" && !goIdentifierPattern.Match([]byte(opts.ConstructorPrefix)) { + return false, fmt.Errorf("constructor-`prefix `%s` is illegal", opts.ConstructorPrefix) + } + return false, nil } diff --git a/internal/mockgen/generation/generate.go b/internal/mockgen/generation/generate.go index 8a135a2..72aade5 100644 --- a/internal/mockgen/generation/generate.go +++ b/internal/mockgen/generation/generate.go @@ -25,6 +25,7 @@ type Options struct { OutputDir string OutputImportPath string Prefix string + ConstructorPrefix string Force bool DisableFormatting bool GoImportsBinary string @@ -105,7 +106,7 @@ func generateAndRender(ifaces []*types.Interface, filename string, opts *Options pkgName += "_test" } - content, err := generateContent(ifaces, pkgName, opts.Prefix, opts.OutputImportPath) + content, err := generateContent(ifaces, pkgName, opts.Prefix, opts.ConstructorPrefix, opts.OutputImportPath) if err != nil { return err } @@ -131,13 +132,13 @@ func generateAndRender(ifaces []*types.Interface, filename string, opts *Options return nil } -func generateContent(ifaces []*types.Interface, pkgName, prefix, outputImportPath string) (string, error) { +func generateContent(ifaces []*types.Interface, pkgName, prefix, constructorPrefix, outputImportPath string) (string, error) { file := jen.NewFile(pkgName) file.HeaderComment(fmt.Sprintf("Code generated by %s %s; DO NOT EDIT.", consts.Name, consts.Version)) for _, iface := range ifaces { log.Printf("generating code for interface '%s'\n", iface.Name) - generateInterface(file, iface, prefix, outputImportPath) + generateInterface(file, iface, prefix, constructorPrefix, outputImportPath) } buffer := &bytes.Buffer{} @@ -148,12 +149,18 @@ func generateContent(ifaces []*types.Interface, pkgName, prefix, outputImportPat return buffer.String(), nil } -func generateInterface(file *jen.File, iface *types.Interface, prefix, outputImportPath string) { +func generateInterface(file *jen.File, iface *types.Interface, prefix, constructorPrefix, outputImportPath string) { + withConstructorPrefix := func(f func(*wrappedInterface, string, string) jen.Code) func(*wrappedInterface, string) jen.Code { + return func(iface *wrappedInterface, outputImportPath string) jen.Code { + return f(iface, constructorPrefix, outputImportPath) + } + } + topLevelGenerators := []func(*wrappedInterface, string) jen.Code{ generateMockStruct, - generateMockStructConstructor, - generateMockStructStrictConstructor, - generateMockStructFromConstructor, + withConstructorPrefix(generateMockStructConstructor), + withConstructorPrefix(generateMockStructStrictConstructor), + withConstructorPrefix(generateMockStructFromConstructor), } methodGenerators := []func(*wrappedInterface, *wrappedMethod, string) jen.Code{ diff --git a/internal/mockgen/generation/generate_constructors.go b/internal/mockgen/generation/generate_constructors.go index 5dd8ad1..e1ce1ac 100644 --- a/internal/mockgen/generation/generate_constructors.go +++ b/internal/mockgen/generation/generate_constructors.go @@ -9,12 +9,12 @@ import ( "github.com/derision-test/go-mockgen/internal/mockgen/types" ) -func generateMockStructConstructor(iface *wrappedInterface, outputImportPath string) jen.Code { +func generateMockStructConstructor(iface *wrappedInterface, constructorPrefix, outputImportPath string) jen.Code { makeField := func(method *wrappedMethod) jen.Code { return makeDefaultHookField(iface, method, generateNoopFunction(iface, method, outputImportPath)) } - name := fmt.Sprintf("New%s", iface.mockStructName) + name := fmt.Sprintf("New%s%s", constructorPrefix, iface.mockStructName) commentText := []string{ fmt.Sprintf(`%s creates a new mock of the %s interface.`, name, iface.Name), `All methods return zero values for all results, unless overwritten.`, @@ -22,12 +22,12 @@ func generateMockStructConstructor(iface *wrappedInterface, outputImportPath str return generateConstructor(iface, strings.Join(commentText, " "), name, nil, makeField) } -func generateMockStructStrictConstructor(iface *wrappedInterface, outputImportPath string) jen.Code { +func generateMockStructStrictConstructor(iface *wrappedInterface, constructorPrefix, outputImportPath string) jen.Code { makeField := func(method *wrappedMethod) jen.Code { return makeDefaultHookField(iface, method, generatePanickingFunction(iface, method, outputImportPath)) } - name := fmt.Sprintf("NewStrict%s", iface.mockStructName) + name := fmt.Sprintf("NewStrict%s%s", constructorPrefix, iface.mockStructName) commentText := []string{ fmt.Sprintf(`%s creates a new mock of the %s interface.`, name, iface.Name), `All methods panic on invocation, unless overwritten.`, @@ -35,27 +35,27 @@ func generateMockStructStrictConstructor(iface *wrappedInterface, outputImportPa return generateConstructor(iface, strings.Join(commentText, " "), name, nil, makeField) } -func generateMockStructFromConstructor(iface *wrappedInterface, outputImportPath string) jen.Code { +func generateMockStructFromConstructor(iface *wrappedInterface, constructorPrefix, outputImportPath string) jen.Code { if !unicode.IsUpper([]rune(iface.Name)[0]) { surrogateStructName := fmt.Sprintf("surrogateMock%s", iface.titleName) surrogateDefinition := generateSurrogateInterface(iface, surrogateStructName) name := jen.Id(surrogateStructName) - constructor := generateMockStructFromConstructorCommon(iface, name) + constructor := generateMockStructFromConstructorCommon(iface, name, constructorPrefix) return compose(surrogateDefinition, constructor) } importPath := sanitizeImportPath(iface.ImportPath, outputImportPath) name := jen.Qual(importPath, iface.Name) - return generateMockStructFromConstructorCommon(iface, name) + return generateMockStructFromConstructorCommon(iface, name, constructorPrefix) } -func generateMockStructFromConstructorCommon(iface *wrappedInterface, ifaceName *jen.Statement) jen.Code { +func generateMockStructFromConstructorCommon(iface *wrappedInterface, ifaceName *jen.Statement, constructorPrefix string) jen.Code { makeField := func(method *wrappedMethod) jen.Code { // i. return makeDefaultHookField(iface, method, jen.Id("i").Dot(method.Name)) } - name := fmt.Sprintf("New%sFrom", iface.mockStructName) + name := fmt.Sprintf("New%s%sFrom", constructorPrefix, iface.mockStructName) commentText := []string{ fmt.Sprintf(`%s creates a new mock of the %s interface.`, name, iface.mockStructName), `All methods delegate to the given implementation, unless overwritten.`, diff --git a/internal/mockgen/generation/generate_constructors_test.go b/internal/mockgen/generation/generate_constructors_test.go index 9ef18aa..d916c98 100644 --- a/internal/mockgen/generation/generate_constructors_test.go +++ b/internal/mockgen/generation/generate_constructors_test.go @@ -8,7 +8,7 @@ import ( ) func TestGenerateMockStructConstructor(t *testing.T) { - code := generateMockStructConstructor(makeInterface(TestMethodStatus, TestMethodDo, TestMethodDof)) + code := generateMockStructConstructor(makeInterface(TestMethodStatus, TestMethodDo, TestMethodDof), "", "") expected := strip(` // NewMockTestClient creates a new mock of the Client interface. All methods // return zero values for all results, unless overwritten. @@ -36,7 +36,7 @@ func TestGenerateMockStructConstructor(t *testing.T) { } func TestGenerateMockStructStrictConstructor(t *testing.T) { - code := generateMockStructStrictConstructor(makeInterface(TestMethodStatus, TestMethodDo, TestMethodDof)) + code := generateMockStructStrictConstructor(makeInterface(TestMethodStatus, TestMethodDo, TestMethodDof), "", "") expected := strip(` // NewStrictMockTestClient creates a new mock of the Client interface. All // methods panic on invocation, unless overwritten. @@ -64,7 +64,7 @@ func TestGenerateMockStructStrictConstructor(t *testing.T) { } func TestGenerateMockStructFromConstructor(t *testing.T) { - code := generateMockStructFromConstructor(makeInterface(TestMethodStatus, TestMethodDo, TestMethodDof)) + code := generateMockStructFromConstructor(makeInterface(TestMethodStatus, TestMethodDo, TestMethodDof), "", "") expected := strip(` // NewMockTestClientFrom creates a new mock of the MockTestClient interface. // All methods delegate to the given implementation, unless overwritten. @@ -88,7 +88,7 @@ func TestGenerateMockStructFromConstructor(t *testing.T) { func TestGenerateMockStructFromConstructorUnexported(t *testing.T) { iface := makeBareInterface(TestMethodStatus, TestMethodDo, TestMethodDof) iface.Name = "client" - code := generateMockStructFromConstructor(wrapInterface(iface, TestPrefix, TestTitleName, TestMockStructName, ""), "") + code := generateMockStructFromConstructor(wrapInterface(iface, TestPrefix, TestTitleName, TestMockStructName, ""), "", "") expected := strip(` // surrogateMockClient is a copy of the client interface (from the package diff --git a/internal/mockgen/generation/generate_mock_func_call_methods_test.go b/internal/mockgen/generation/generate_mock_func_call_methods_test.go index f70c27a..e1b1d56 100644 --- a/internal/mockgen/generation/generate_mock_func_call_methods_test.go +++ b/internal/mockgen/generation/generate_mock_func_call_methods_test.go @@ -8,7 +8,8 @@ import ( ) func TestGenerateMockFuncCallArgsMethod(t *testing.T) { - code := generateMockFuncCallArgsMethod(makeMethod(TestMethodDo)) + wrappedInterface := makeInterface(TestMethodDo) + code := generateMockFuncCallArgsMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // Args returns an interface slice containing the arguments of this // invocation. @@ -20,7 +21,8 @@ func TestGenerateMockFuncCallArgsMethod(t *testing.T) { } func TestGenerateMockFuncCallArgsMethodVariadic(t *testing.T) { - code := generateMockFuncCallArgsMethod(makeMethod(TestMethodDof)) + wrappedInterface := makeInterface(TestMethodDof) + code := generateMockFuncCallArgsMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // Args returns an interface slice containing the arguments of this // invocation. The variadic slice argument is flattened in this array such @@ -39,7 +41,8 @@ func TestGenerateMockFuncCallArgsMethodVariadic(t *testing.T) { } func TestGenerateMockFuncCallResultsMethod(t *testing.T) { - code := generateMockFuncCallResultsMethod(makeMethod(TestMethodDo)) + wrappedInterface := makeInterface(TestMethodDo) + code := generateMockFuncCallResultsMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // Results returns an interface slice containing the results of this // invocation. @@ -51,7 +54,8 @@ func TestGenerateMockFuncCallResultsMethod(t *testing.T) { } func TestGenerateMockFuncCallResultsMethodMultiple(t *testing.T) { - code := generateMockFuncCallResultsMethod(makeMethod(TestMethodStatus)) + wrappedInterface := makeInterface(TestMethodStatus) + code := generateMockFuncCallResultsMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // Results returns an interface slice containing the results of this // invocation. diff --git a/internal/mockgen/generation/generate_mock_func_methods_test.go b/internal/mockgen/generation/generate_mock_func_methods_test.go index ecad991..0d12541 100644 --- a/internal/mockgen/generation/generate_mock_func_methods_test.go +++ b/internal/mockgen/generation/generate_mock_func_methods_test.go @@ -8,7 +8,8 @@ import ( ) func TestGenerateMockFuncSetHookMethod(t *testing.T) { - code := generateMockFuncSetHookMethod(makeMethod(TestMethodDo)) + wrappedInterface := makeInterface(TestMethodDo) + code := generateMockFuncSetHookMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // SetDefaultHook sets function that is called when the Do method of the // parent MockTestClient instance is invoked and the hook queue is empty. @@ -20,7 +21,8 @@ func TestGenerateMockFuncSetHookMethod(t *testing.T) { } func TestGenerateMockFuncSetHookMethodVariadic(t *testing.T) { - code := generateMockFuncSetHookMethod(makeMethod(TestMethodDof)) + wrappedInterface := makeInterface(TestMethodDof) + code := generateMockFuncSetHookMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // SetDefaultHook sets function that is called when the Dof method of the // parent MockTestClient instance is invoked and the hook queue is empty. @@ -32,7 +34,8 @@ func TestGenerateMockFuncSetHookMethodVariadic(t *testing.T) { } func TestGenerateMockFuncPushHookMethod(t *testing.T) { - code := generateMockFuncPushHookMethod(makeMethod(TestMethodDo)) + wrappedInterface := makeInterface(TestMethodDo) + code := generateMockFuncPushHookMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // PushHook adds a function to the end of hook queue. Each invocation of the // Do method of the parent MockTestClient instance invokes the hook at the @@ -48,7 +51,8 @@ func TestGenerateMockFuncPushHookMethod(t *testing.T) { } func TestGenerateMockFuncPushHookMethodVariadic(t *testing.T) { - code := generateMockFuncPushHookMethod(makeMethod(TestMethodDof)) + wrappedInterface := makeInterface(TestMethodDof) + code := generateMockFuncPushHookMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // PushHook adds a function to the end of hook queue. Each invocation of the // Dof method of the parent MockTestClient instance invokes the hook at the @@ -64,7 +68,8 @@ func TestGenerateMockFuncPushHookMethodVariadic(t *testing.T) { } func TestGenerateMockFuncSetReturnMethod(t *testing.T) { - code := generateMockFuncSetReturnMethod(makeMethod(TestMethodDo)) + wrappedInterface := makeInterface(TestMethodDo) + code := generateMockFuncSetReturnMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // SetDefaultReturn calls SetDefaultHook with a function that returns the // given values. @@ -78,7 +83,8 @@ func TestGenerateMockFuncSetReturnMethod(t *testing.T) { } func TestGenerateMockFuncPushReturnMethod(t *testing.T) { - code := generateMockFuncPushReturnMethod(makeMethod(TestMethodDo)) + wrappedInterface := makeInterface(TestMethodDo) + code := generateMockFuncPushReturnMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // PushReturn calls PushHook with a function that returns the given values. func (f *TestClientDoFunc) PushReturn(r0 bool) { @@ -91,7 +97,8 @@ func TestGenerateMockFuncPushReturnMethod(t *testing.T) { } func TestGenerateMockFuncNextHookMethod(t *testing.T) { - code := generateMockFuncNextHookMethod(makeMethod(TestMethodDo)) + wrappedInterface := makeInterface(TestMethodDo) + code := generateMockFuncNextHookMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` func (f *TestClientDoFunc) nextHook() func(string) bool { f.mutex.Lock() @@ -110,7 +117,8 @@ func TestGenerateMockFuncNextHookMethod(t *testing.T) { } func TestGenerateMockFuncAppendCallMethod(t *testing.T) { - code := generateMockFuncAppendCallMethod(makeMethod(TestMethodDo)) + wrappedInterface := makeInterface(TestMethodDo) + code := generateMockFuncAppendCallMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` func (f *TestClientDoFunc) appendCall(r0 TestClientDoFuncCall) { f.mutex.Lock() @@ -122,7 +130,8 @@ func TestGenerateMockFuncAppendCallMethod(t *testing.T) { } func TestGenerateMockFuncHistoryMethod(t *testing.T) { - code := generateMockFuncHistoryMethod(makeMethod(TestMethodDo)) + wrappedInterface := makeInterface(TestMethodDo) + code := generateMockFuncHistoryMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // History returns a sequence of TestClientDoFuncCall objects describing the // invocations of this function. diff --git a/internal/mockgen/generation/generate_mock_methods_test.go b/internal/mockgen/generation/generate_mock_methods_test.go index 7ea0a0a..a9d9afe 100644 --- a/internal/mockgen/generation/generate_mock_methods_test.go +++ b/internal/mockgen/generation/generate_mock_methods_test.go @@ -8,7 +8,8 @@ import ( ) func TestGenerateMockInterfaceMethod(t *testing.T) { - code := generateMockInterfaceMethod(makeMethod(TestMethodDo)) + wrappedInterface := makeInterface(TestMethodDo) + code := generateMockInterfaceMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // Do delegates to the next hook function in the queue and stores the // parameter and result values of this invocation. @@ -22,7 +23,8 @@ func TestGenerateMockInterfaceMethod(t *testing.T) { } func TestGenerateMockInterfaceMethodVariadic(t *testing.T) { - code := generateMockInterfaceMethod(makeMethod(TestMethodDof)) + wrappedInterface := makeInterface(TestMethodDof) + code := generateMockInterfaceMethod(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // Dof delegates to the next hook function in the queue and stores the // parameter and result values of this invocation. diff --git a/internal/mockgen/generation/generate_structs_test.go b/internal/mockgen/generation/generate_structs_test.go index ccc4b7f..46a2848 100644 --- a/internal/mockgen/generation/generate_structs_test.go +++ b/internal/mockgen/generation/generate_structs_test.go @@ -8,7 +8,7 @@ import ( ) func TestGenerateMockStruct(t *testing.T) { - code := generateMockStruct(makeInterface(TestMethodStatus, TestMethodDo, TestMethodDof)) + code := generateMockStruct(makeInterface(TestMethodStatus, TestMethodDo, TestMethodDof), "") expected := strip(` // MockTestClient is a mock implementation of the Client interface (from the // package github.com/derision-test/go-mockgen/test) used for unit testing. @@ -28,7 +28,8 @@ func TestGenerateMockStruct(t *testing.T) { } func TestGenerateFuncStruct(t *testing.T) { - code := generateMockFuncStruct(makeMethod(TestMethodDo)) + wrappedInterface := makeInterface(TestMethodDo) + code := generateMockFuncStruct(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // TestClientDoFunc describes the behavior when the Do method of the parent // MockTestClient instance is invoked. @@ -43,7 +44,8 @@ func TestGenerateFuncStruct(t *testing.T) { } func TestGenerateFuncStructVariadic(t *testing.T) { - code := generateMockFuncStruct(makeMethod(TestMethodDof)) + wrappedInterface := makeInterface(TestMethodDof) + code := generateMockFuncStruct(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // TestClientDofFunc describes the behavior when the Dof method of the // parent MockTestClient instance is invoked. @@ -58,7 +60,8 @@ func TestGenerateFuncStructVariadic(t *testing.T) { } func TestGenerateMockFuncCallStruct(t *testing.T) { - code := generateMockFuncCallStruct(makeMethod(TestMethodDo)) + wrappedInterface := makeInterface(TestMethodDo) + code := generateMockFuncCallStruct(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // TestClientDoFuncCall is an object that describes an invocation of method // Do on an instance of MockTestClient. @@ -75,7 +78,8 @@ func TestGenerateMockFuncCallStruct(t *testing.T) { } func TestGenerateMockFuncCallStructVariadic(t *testing.T) { - code := generateMockFuncCallStruct(makeMethod(TestMethodDof)) + wrappedInterface := makeInterface(TestMethodDof) + code := generateMockFuncCallStruct(wrappedInterface, wrappedInterface.wrappedMethods[0], "") expected := strip(` // TestClientDofFuncCall is an object that describes an invocation of method // Dof on an instance of MockTestClient. diff --git a/internal/mockgen/generation/generate_test.go b/internal/mockgen/generation/generate_test.go index d1f6420..038184e 100644 --- a/internal/mockgen/generation/generate_test.go +++ b/internal/mockgen/generation/generate_test.go @@ -42,7 +42,7 @@ func TestGenerateInterface(t *testing.T) { file := jen.NewFile("test") - generateInterface(file, makeBareInterface(TestMethodDo, TestMethodDof), TestPrefix, "") + generateInterface(file, makeBareInterface(TestMethodDo, TestMethodDof), TestPrefix, "", "") rendered := fmt.Sprintf("%#v\n", file) for _, decl := range expectedDecls { diff --git a/internal/mockgen/generation/helpers_test.go b/internal/mockgen/generation/helpers_test.go index e8245dd..8141b38 100644 --- a/internal/mockgen/generation/helpers_test.go +++ b/internal/mockgen/generation/helpers_test.go @@ -51,13 +51,13 @@ func makeBareInterface(methods ...*types.Method) *types.Interface { } } -func makeInterface(methods ...*types.Method) (*wrappedInterface, string) { - return wrapInterface(makeBareInterface(methods...), TestPrefix, TestTitleName, TestMockStructName, ""), "" +func makeInterface(methods ...*types.Method) *wrappedInterface { + return wrapInterface(makeBareInterface(methods...), TestPrefix, TestTitleName, TestMockStructName, "") } -func makeMethod(methods ...*types.Method) (*wrappedInterface, *wrappedMethod, string) { - wrapped, _ := makeInterface(methods...) - return wrapped, wrapped.wrappedMethods[0], "" +func makeMethod(methods ...*types.Method) (*wrappedInterface, *wrappedMethod) { + wrapped := makeInterface(methods...) + return wrapped, wrapped.wrappedMethods[0] } func strip(block string) string {