-
Notifications
You must be signed in to change notification settings - Fork 93
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
counterfeiter does not check vendor directory when generating using import path #75
Comments
So if I understand the use case correctly here ... There is a vendored library in your project, and it exports an interface. It's their interface that you want to generate a fake for? I'm not totally opposed to supporting this behavior, but I am amazed at how the complexity of vendor paths and gopaths makes it hard to tell someone simply how One possible alternative to what you've suggested here would be to have your project define a type alias for the interface you want to mock. That way the interface would be in your project, and easier to find. From my own experience, and the teams within cloud foundry, the preferred Go coding style is to define interfaces closer to where you consume them, in the way I've described here. |
Yes. |
You're right, it would become more complex, but on the other hand, having it find the package in I'll try to write some tests, but I don't know when I'll have time to do that. For now I've forked counterfeiter, because I need these fixes for a project I'm working on. |
Is there any progress in solving this? |
Yeah I'd definitely love this behavior :) |
Just ran into this issue and your suggested type alias workaround isn't a solution. In my case, I'm pulling in two difference dependencies whose interfaces interact. |
Here is an ugly workaround to this problem:
After this running Note: gsed only works on osx (when gnu-sed is installed), if you want this to work on linux, use sed. |
This replaces the mock from the gpio package, and removes the last usage og gomock. It's been necessary to use a somewhat ugly workaround to generate the fake from the vendored gpio package due to an outstanding counterfeitter issue[1]. I've used perl instead of sed for the substitution so that it's portable across Mac and Linux. [1] maxbrunsfeld/counterfeiter#75
This replaces the mock from the gpio package, and removes the last usage og gomock. It's been necessary to use a somewhat ugly workaround to generate the fake from the vendored gpio package due to an outstanding counterfeitter issue[1]. I've used perl instead of sed for the substitution so that it's portable across Mac and Linux. [1] maxbrunsfeld/counterfeiter#75
This replaces the mock from the gpio package, and removes the last usage og gomock. It's been necessary to use a somewhat ugly workaround to generate the fake from the vendored gpio package due to an outstanding counterfeitter issue[1]. I've used perl instead of sed for the substitution so that it's portable across Mac and Linux. [1] maxbrunsfeld/counterfeiter#75
This replaces the mock from the gpio package, and removes the last usage og gomock. It's been necessary to use a somewhat ugly workaround to generate the fake from the vendored gpio package due to an outstanding counterfeitter issue[1]. I've used perl instead of sed for the substitution so that it's portable across Mac and Linux. [1] maxbrunsfeld/counterfeiter#75
- Fixed some bugs - Fixed for empty responses - Fixed for responses with no new versions - Some changes to wording - Add counterfeiter-generated fakes for go-concourse. Due to a known bug, I had to edit these manually to use a non-vendor import path in the generated code. See: maxbrunsfeld/counterfeiter#75 [#4] Signed-off-by: Jacques Chester <jchester@pivotal.io>
As with pkg/check, there are a few changes. - Fixed trying to read error message from nil errors on 404s - Some changes to wording - Added counterfeiter-generated fakes for eventstream. Due to a known bug, I had to manually edit the fake file to use a non-vendor import path in the generated code. This also arose in bbc3538. See: See: maxbrunsfeld/counterfeiter#75 [#4] Signed-off-by: Jacques Chester <jchester@pivotal.io>
I think this will be fixed by #94, please check out that PR. |
This does not seem to be working as expected. Counterfeiter now uses |
This is an issue with go/packages, there's workaround: golang/go#30289 |
When you have a vendored library in your project and you use a fully qualified import path to generate a fake, counterfeiter won't search for it in the vendored directory.
E.g.:
The text was updated successfully, but these errors were encountered: