Skip to content

Commit

Permalink
reproduce issue #174
Browse files Browse the repository at this point in the history
  • Loading branch information
joefitzgerald committed Apr 19, 2021
1 parent ba255fd commit 6c67c66
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 141 deletions.
4 changes: 0 additions & 4 deletions fixtures/externalpkg/aliased_interface.go

This file was deleted.

67 changes: 0 additions & 67 deletions fixtures/externalpkg/externalpkgfakes/fake_context.go

This file was deleted.

9 changes: 6 additions & 3 deletions fixtures/internalpkg/aliased_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ package internalpkg

import "github.com/maxbrunsfeld/counterfeiter/v6/fixtures/internalpkg/internal"

//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
//counterfeiter:generate . Context

type Context = internal.Context

//go:generate go run github.com/maxbrunsfeld/counterfeiter/v6 -generate
//counterfeiter:generate . MyInterface
type MyInterface interface {
MyFunc(ctx Context)
}
3 changes: 3 additions & 0 deletions fixtures/internalpkg/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/maxbrunsfeld/counterfeiter/v6/fixtures/internalpkg

go 1.12
67 changes: 0 additions & 67 deletions fixtures/internalpkg/internalpkgfakes/fake_context.go

This file was deleted.

77 changes: 77 additions & 0 deletions fixtures/internalpkg/internalpkgfakes/fake_my_interface.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions integration/roundtrip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,4 +224,35 @@ func runTests(t *testing.T, when spec.G, it spec.S) {
t("AliasV1", "", "dup_packagesfakes")
})
})

when("working with internal packages", func() {
t := func(interfaceName string, offset string, fakePackageName string) {
when("working with "+interfaceName, func() {
it.Before(func() {
relativeDir = filepath.Join(relativeDir, "internalpkg")
copyDirFunc()
})

it.Focus("succeeds", func() {
pkgPath := "github.com/maxbrunsfeld/counterfeiter/v6/fixtures/internalpkg"
if offset != "" {
pkgPath = pkgPath + "/" + offset
}
cache := &generator.FakeCache{}
f, err := generator.NewFake(generator.InterfaceOrFunction, interfaceName, pkgPath, "Fake"+interfaceName, fakePackageName, "", baseDir, cache)
Expect(err).NotTo(HaveOccurred())
b, err := f.Generate(false) // Flip to false to see output if goimports fails
Expect(err).NotTo(HaveOccurred())
if writeToTestData {
WriteOutput(b, filepath.Join("testdata", "output", "internalpkg_"+strings.ToLower(interfaceName), "actual.go"))
}
WriteOutput(b, filepath.Join(baseDir, offset, fakePackageName, "fake_"+strings.ToLower(interfaceName)+".go"))
RunBuild(filepath.Join(baseDir, offset, fakePackageName))
Expect(string(b)).NotTo(ContainSubstring("internal.Context"))
})
})
}

t("MyInterface", "", "internalpkgfakes")
})
}

0 comments on commit 6c67c66

Please sign in to comment.