golang / mock

GoMock is a mocking framework for the Go programming language.
Apache License 2.0
9.26k stars 608 forks source link

constants / custom types are absent in mock file #629

Closed mangup closed 2 years ago

mangup commented 2 years ago

Actual behavior A clear and concise description of what the bug is.

Period type is not defined in mock file

Expected behavior A clear and concise description of what you expected to happen.

Period type is defined in mock file

To Reproduce Steps to reproduce the behavior

type Period uint const ( Day Period = iota Month ) type Foo interface { GetData(p Period) (uint, error) }

  1. mock file with code above
  2. ...

Additional Information

Triage Notes for the Maintainers

codyoss commented 2 years ago

This is by design, that type should only live in one place, in your source code. Mocks depend on all sorts of types not defined in the mock file to make sure they can be tested with the actual types required.