diff --git a/cmd/minimock/minimock.go b/cmd/minimock/minimock.go index 2dbc7c9..2204482 100644 --- a/cmd/minimock/minimock.go +++ b/cmd/minimock/minimock.go @@ -148,6 +148,8 @@ func processPackage(opts generator.Options, interfaces []types.InterfaceSpecific return errors.Wrapf(err, "failed to generate mock for %s", iface.InterfaceName) } + opts.HeaderVars["OutputFile"] = filepath.Base(opts.OutputFile) + opts.Vars["MockName"] = fmt.Sprintf("%sMock", opts.InterfaceName) if mockName != "" { opts.Vars["MockName"] = mockName diff --git a/template.go b/template.go index 291cdda..1f16b3f 100644 --- a/template.go +++ b/template.go @@ -8,7 +8,7 @@ const ( // Code generated by http://github.com/gojuno/minimock ({{$.Options.HeaderVars.Version}}). DO NOT EDIT. {{if $.Options.HeaderVars.GenerateInstruction}} - //go:generate minimock -i {{$.SourcePackage.PkgPath}}.{{$.Options.InterfaceName}} -o {{$.Options.OutputFile}} -n {{(title (index $.Vars "MockName"))}} + //go:generate minimock -i {{$.SourcePackage.PkgPath}}.{{$.Options.InterfaceName}} -o {{$.Options.HeaderVars.OutputFile}} -n {{(title (index $.Vars "MockName"))}} {{end}} import ( diff --git a/tests/context_accepter_mock.go b/tests/context_accepter_mock.go index 854bd1a..dabc3b4 100644 --- a/tests/context_accepter_mock.go +++ b/tests/context_accepter_mock.go @@ -2,7 +2,7 @@ package tests // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. -//go:generate minimock -i github.com/gojuno/minimock/v3/tests.contextAccepter -o ./tests/context_accepter_mock.go -n ContextAccepterMock +//go:generate minimock -i github.com/gojuno/minimock/v3/tests.contextAccepter -o context_accepter_mock.go -n ContextAccepterMock import ( "context" diff --git a/tests/formatter_mock.go b/tests/formatter_mock.go index c0a0916..50014d2 100644 --- a/tests/formatter_mock.go +++ b/tests/formatter_mock.go @@ -2,7 +2,7 @@ package tests // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. -//go:generate minimock -i github.com/gojuno/minimock/v3/tests.Formatter -o ./tests/formatter_mock.go -n FormatterMock +//go:generate minimock -i github.com/gojuno/minimock/v3/tests.Formatter -o formatter_mock.go -n FormatterMock import ( "sync" diff --git a/tests/formatter_with_custom_name_mock.go b/tests/formatter_with_custom_name_mock.go index 473b2b5..bc6bc60 100644 --- a/tests/formatter_with_custom_name_mock.go +++ b/tests/formatter_with_custom_name_mock.go @@ -2,7 +2,7 @@ package tests // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. -//go:generate minimock -i github.com/gojuno/minimock/v3/tests.Formatter -o ./tests/formatter_with_custom_name_mock.go -n CustomFormatterNameMock +//go:generate minimock -i github.com/gojuno/minimock/v3/tests.Formatter -o formatter_with_custom_name_mock.go -n CustomFormatterNameMock import ( "sync" @@ -108,7 +108,7 @@ func (mmFormat *mCustomFormatterNameMockFormat) Return(s2 string) *CustomFormatt return mmFormat.mock } -//Set uses given function f to mock the Formatter.Format method +// Set uses given function f to mock the Formatter.Format method func (mmFormat *mCustomFormatterNameMockFormat) Set(f func(s1 string, p1 ...interface{}) (s2 string)) *CustomFormatterNameMock { if mmFormat.defaultExpectation != nil { mmFormat.mock.t.Fatalf("Default expectation is already set for the Formatter.Format method") @@ -152,15 +152,15 @@ func (mmFormat *CustomFormatterNameMock) Format(s1 string, p1 ...interface{}) (s mmFormat.inspectFuncFormat(s1, p1...) } - mm_params := &CustomFormatterNameMockFormatParams{s1, p1} + mm_params := CustomFormatterNameMockFormatParams{s1, p1} // Record call args mmFormat.FormatMock.mutex.Lock() - mmFormat.FormatMock.callArgs = append(mmFormat.FormatMock.callArgs, mm_params) + mmFormat.FormatMock.callArgs = append(mmFormat.FormatMock.callArgs, &mm_params) mmFormat.FormatMock.mutex.Unlock() for _, e := range mmFormat.FormatMock.expectations { - if minimock.Equal(e.params, mm_params) { + if minimock.Equal(*e.params, mm_params) { mm_atomic.AddUint64(&e.Counter, 1) return e.results.s2 } diff --git a/tests/generic_complex_union.go b/tests/generic_complex_union.go index e3b6d43..83223e1 100644 --- a/tests/generic_complex_union.go +++ b/tests/generic_complex_union.go @@ -2,7 +2,7 @@ package tests // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. -//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericComplexUnion -o ./tests/generic_complex_union.go -n GenericComplexUnionMock +//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericComplexUnion -o generic_complex_union.go -n GenericComplexUnionMock import ( "sync" diff --git a/tests/generic_in.go b/tests/generic_in.go index 07cfd82..34cc53b 100644 --- a/tests/generic_in.go +++ b/tests/generic_in.go @@ -2,7 +2,7 @@ package tests // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. -//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericIn -o ./tests/generic_in.go -n GenericInMock +//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericIn -o generic_in.go -n GenericInMock import ( "sync" @@ -12,7 +12,7 @@ import ( "github.com/gojuno/minimock/v3" ) -// GenericInMock implements tests.genericIn +// GenericInMock implements genericIn type GenericInMock[T any] struct { t minimock.Tester @@ -23,7 +23,7 @@ type GenericInMock[T any] struct { NameMock mGenericInMockName[T] } -// NewGenericInMock returns a mock for tests.genericIn +// NewGenericInMock returns a mock for genericIn func NewGenericInMock[T any](t minimock.Tester) *GenericInMock[T] { m := &GenericInMock[T]{t: t} if controller, ok := t.(minimock.MockController); ok { @@ -116,7 +116,7 @@ func (mmName *mGenericInMockName[T]) Set(f func(t1 T)) *GenericInMock[T] { return mmName.mock } -// Name implements tests.genericIn +// Name implements genericIn func (mmName *GenericInMock[T]) Name(t1 T) { mm_atomic.AddUint64(&mmName.beforeNameCounter, 1) defer mm_atomic.AddUint64(&mmName.afterNameCounter, 1) diff --git a/tests/generic_inline_union.go b/tests/generic_inline_union.go index 75c4dd7..3954bf7 100644 --- a/tests/generic_inline_union.go +++ b/tests/generic_inline_union.go @@ -2,7 +2,7 @@ package tests // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. -//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericInlineUnion -o ./tests/generic_inline_union.go -n GenericInlineUnionMock +//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericInlineUnion -o generic_inline_union.go -n GenericInlineUnionMock import ( "sync" diff --git a/tests/generic_inline_with_many_options.go b/tests/generic_inline_with_many_options.go index 9857dab..4256ce3 100644 --- a/tests/generic_inline_with_many_options.go +++ b/tests/generic_inline_with_many_options.go @@ -2,7 +2,7 @@ package tests // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. -//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericInlineUnionWithManyTypes -o ./tests/generic_inline_with_many_options.go -n GenericInlineUnionWithManyTypesMock +//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericInlineUnionWithManyTypes -o generic_inline_with_many_options.go -n GenericInlineUnionWithManyTypesMock import ( "sync" diff --git a/tests/generic_inout.go b/tests/generic_inout.go index b297ec7..cf49764 100644 --- a/tests/generic_inout.go +++ b/tests/generic_inout.go @@ -2,7 +2,7 @@ package tests // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. -//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericInout -o ./tests/generic_inout.go -n GenericInoutMock +//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericInout -o generic_inout.go -n GenericInoutMock import ( "sync" diff --git a/tests/generic_multiple_args_with_different_types.go b/tests/generic_multiple_args_with_different_types.go index e913d8a..ba49123 100644 --- a/tests/generic_multiple_args_with_different_types.go +++ b/tests/generic_multiple_args_with_different_types.go @@ -2,7 +2,7 @@ package tests // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. -//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericMultipleTypes -o ./tests/generic_multiple_args_with_different_types.go -n GenericMultipleTypesMock +//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericMultipleTypes -o generic_multiple_args_with_different_types.go -n GenericMultipleTypesMock import ( "sync" diff --git a/tests/generic_out.go b/tests/generic_out.go index 528e9a5..dffb48b 100644 --- a/tests/generic_out.go +++ b/tests/generic_out.go @@ -2,7 +2,7 @@ package tests // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. -//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericOut -o ./tests/generic_out.go -n GenericOutMock +//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericOut -o generic_out.go -n GenericOutMock import ( mm_atomic "sync/atomic" diff --git a/tests/generic_simple_union.go b/tests/generic_simple_union.go index e378211..7f75a20 100644 --- a/tests/generic_simple_union.go +++ b/tests/generic_simple_union.go @@ -2,7 +2,7 @@ package tests // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. -//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericSimpleUnion -o ./tests/generic_simple_union.go -n GenericSimpleUnionMock +//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericSimpleUnion -o generic_simple_union.go -n GenericSimpleUnionMock import ( "sync" diff --git a/tests/generic_specific.go b/tests/generic_specific.go index cbfb141..135c690 100644 --- a/tests/generic_specific.go +++ b/tests/generic_specific.go @@ -2,7 +2,7 @@ package tests // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. -//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericSpecific -o ./tests/generic_specific.go -n GenericSpecificMock +//go:generate minimock -i github.com/gojuno/minimock/v3/tests.genericSpecific -o generic_specific.go -n GenericSpecificMock import ( "sync" diff --git a/tests/tester_mock_test.go b/tests/tester_mock_test.go index 1146b9c..2572b6a 100644 --- a/tests/tester_mock_test.go +++ b/tests/tester_mock_test.go @@ -2,7 +2,7 @@ package tests // Code generated by http://github.com/gojuno/minimock (dev). DO NOT EDIT. -//go:generate minimock -i github.com/gojuno/minimock/v3.Tester -o ./tests/tester_mock_test.go -n TesterMock +//go:generate minimock -i github.com/gojuno/minimock/v3.Tester -o tester_mock_test.go -n TesterMock import ( "sync"