Skip to content

mock_names flag does not change naming of ...Call struct in typed mocks #117

@ojcm

Description

@ojcm

Actual behavior
Using -mock_names option does not alter the name of ...Call structs.

e.g. mockgen -typed=true -mock_names=Writer=OtherWriter io Writer generates

// WriterWriteCall wrap *gomock.Call
type WriterWriteCall struct {
	*gomock.Call
}

This causes problems if using -mock_names to avoid clashes between mocks for interfaces with the same name (e.g. if I have my own Writer interface and also want to mock io.Writer in the same package) since there will be multiple structs with the same type name in the same package.

Expected behavior
I expect using -mock_names option to change the name of ...Call structs.

e.g. mockgen -typed=true -mock_names=Writer=OtherWriter io Writer generates

// OtherWriterWriteCall wrap *gomock.Call
type OtherWriterWriteCall struct {
	*gomock.Call
}

To Reproduce

Run mockgen -typed=true -mock_names=Writer=OtherWriter io Writer

Additional Information

  • gomock mode (reflect or source): both
  • gomock version or git ref: v0.3.0
  • golang version: 1.21.3

Triage Notes for the Maintainers

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions