hel icon indicating copy to clipboard operation
hel copied to clipboard

Package aliases are not replicated in mock

Open myshkin5 opened this issue 9 years ago • 1 comments

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.

myshkin5 avatar Feb 10 '16 17:02 myshkin5

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.

nelsam avatar Feb 17 '16 05:02 nelsam