derision-test / go-mockgen

MIT License
57 stars 7 forks source link

Blacklist support? #11

Closed fr3fou closed 2 years ago

fr3fou commented 2 years ago

Is there a way to disable mocking of a specific interface (I want every interface in a given package, but one)

Slightly unrelated but is there a way to recursively search for interfaces? Something like go-mockgen github.com/foo/bar/baz/...

efritz commented 2 years ago

How about:

Would that behavior be intuitive to you?

fr3fou commented 2 years ago

How about:

  • Making each -p argument takes an optional /... suffix to load the entire code tree under that package
  • Making an -e/exclude flag mutually exclusive to -i that finds all interfaces and filters out the supplied excluded ones

Would that behavior be intuitive to you?

Yep, that'd be perfect! Really liking the mocks generated from this tool as opposed to https://github.com/vektra/mockery Assuming those 2 features get implemented, the only issue left I'll have left is somehow avoiding circular dependencies (package foo/ defines an interface for which go-mockgen generates a mock in mocks/. If I have a test file inside the same package I end up with a cyclic import error. I managed to resolve it by changing the package name to foo_test (but still keeping it in the same directory). Is there a way to automatically place the mocks in the same package as they are defined under a, say mocks_test.go file? The README suggests something along those lines but I'm thinking of something more automatic)

efritz commented 2 years ago

Really liking the mocks generated from this tool

Thank you!

The README suggests something along those lines but I'm thinking of something more automatic)

Would you mind creating a new issue with the expected behavior? As far as I can tell, what you want can be achieved with a combination of existing flags, but you'd like a short-hand/auto-detection for it?

efritz commented 2 years ago

Sorry for the delay, got caught up at $DAYJOB. I'll be handling this issue and #12 by early next week.