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

Package mode is broken #140

Closed
nkovacs opened this issue Jul 25, 2019 · 1 comment
Closed

Package mode is broken #140

nkovacs opened this issue Jul 25, 2019 · 1 comment

Comments

@nkovacs
Copy link
Contributor

nkovacs commented Jul 25, 2019

  1. The error is ignored here: https://github.com/maxbrunsfeld/counterfeiter/blob/master/generator/fake.go#L137. Package generation actually fails, but you get a file with just the package clause and an empty comment.
  2. The error is actually that the template calls .Generate, which is the Fake's Generate method, not the Generate template function.
  3. After fixing these, package mode still doesn't work correctly. The default value of OutputPath is "shim", which is supposed to be a directory, and according to the usage documentation, counterfeiter is supposed to generate two files into that directory: ".go" for the interface and "shim.go" for the shim. Instead it creates a file at OutputPath, and puts both in there.

Side note: the documentation says <output-path> can be a directory or a file. For interface or function mode, it has to be a file. For package mode, it also currently has to be a file, but I don't know if that is intended or not. I also haven't tried older versions of counterfeiter in package mode, but if I remember correctly, the output path always had to be a file for interface or function mode.

@joefitzgerald
Copy link
Collaborator

@nkovacs thanks for your patience on this, I was able to use your suggested fixes, and correct the logic used for the output path. This will be released in v6.4.1.

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

No branches or pull requests

2 participants