From 04f8f063b5f342420cb446900373617e5e11a7df Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Fri, 26 Aug 2016 16:18:11 +0200 Subject: [PATCH] Allow mock-pkg to be the "_test" package Issue #3 --- automock/generator.go | 2 +- cmd/goautomock/main.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/automock/generator.go b/automock/generator.go index 977d86c..8631a4e 100644 --- a/automock/generator.go +++ b/automock/generator.go @@ -26,7 +26,7 @@ type Generator struct { // NewGenerator initializes a Generator that will mock the given interface from the specified package. func NewGenerator(pkg, iface string) (*Generator, error) { - p, err := importer.DefaultWithTestFiles().Import(pkg) + p, err := importer.Default().Import(pkg) if err != nil { return nil, err } diff --git a/cmd/goautomock/main.go b/cmd/goautomock/main.go index b7b4a73..3b80da7 100644 --- a/cmd/goautomock/main.go +++ b/cmd/goautomock/main.go @@ -52,7 +52,7 @@ func main() { if *mockName != "" { gen.SetName(*mockName) } - inPkg := *pkg == "." && path.Dir(*out) == "." + inPkg := *pkg == "." && (path.Dir(*out) == "." && !strings.HasSuffix(*mockPkg, "_test")) gen.SetInternal(inPkg) if *mockPkg == "" && !inPkg { p, err := importer.Default().Import(".")