golang/mock

constants / custom types are absent in mock file

mangup opened this issue · 1 comments

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

  • gomock mode (reflect or source): source
  • gomock version or git ref: github.com/golang/mock v1.6.0
  • golang version: 1.17.7

Triage Notes for the Maintainers

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.