Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Interface fakes generated in the same package as the interface cause an import cycle #103

Open
alexkohler opened this issue Dec 5, 2018 · 5 comments · May be fixed by #135
Open

Interface fakes generated in the same package as the interface cause an import cycle #103

alexkohler opened this issue Dec 5, 2018 · 5 comments · May be fixed by #135

Comments

@alexkohler
Copy link

Suppose you have the following interface:

package abc
//go:generate $GOPATH/src/github.com/maxbrunsfeld/counterfeiter/counterfeiter -o FakeFoo.go . Foo

type Foo interface {
	Bar() error
}

After generating fakes, the output fake includes the following line to ensure FakeFoo is meeting the abc.Foo interface:

var _ abc.Foo = new(FakeFoo)

Note that we output this fake to the abc package, so the abc. identifier in front of Foo is not necessary, and actually causes an import cycle.

@alexkohler
Copy link
Author

I guess this is a duplicate of #68.

@dnephin
Copy link
Contributor

dnephin commented Dec 26, 2018

The problem is not limited to just the interface check. If the interface uses any types defined in the same package for args or returns those types will cause the same problem.

I think the arguments against this in #68 are questionable. White box testing can be just as important as black box testing. In fact this project modifies unexported fields in its tests in many places.

@alexkohler did you find a way to work around the problem? Would you be interested in re-opening this issue or should I open a new one.

@alexkohler
Copy link
Author

@dnephin I did not find a workaround. I was planning on forking and patching, but I'll gladly reopen this for further discussion.

@LasTshaMAN
Copy link

Up! Anything being done in this respect ?

@nkovacs nkovacs linked a pull request Jul 12, 2019 that will close this issue
@jgroeneveld
Copy link

This basically makes this tool unusable.. quite sad, i liked the style

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants