hel
hel copied to clipboard
Package aliases are not replicated in mock
Mock actually ends up being invalid.
Interface:
package foo
import baz "bar"
type Buz interface {
Close() (baz.Thing)
}
Generated a mock with baz
prefixes but no import for baz
or bar
.
It might be surprising, but this is actually kind of a difficult problem. I kinda cheat on imports by just shelling out to goimports
, but that causes all sorts of issues with aliased imports. The ideal solution (IMO) would be to strip out the aliases in the mock and just use the standardized package name, but I haven't dug into that enough to see whether or not it's easy yet.