How can I import mocks from one package into another? #1053
Replies: 1 comment
-
|
What you're asking for is fundamentally not possible without restructuring your code. You can do any of:
Which option would I recommend? 4 is probably the easiest. I do this for all of my test code for this exact reason. The caveat is that |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This might not be possible... I'm using a bare bones mockery config:
And a file structure of:
My
package-bconsumespackage-aand I'd like to be able to use the mocks frompackage-ain mypackage-btests. I have tried generating mocks into a centralisedmocksdirectory like so:But I end up get cyclical import errors during my imports with the mocks using the structs from the package being tested. I then tried moving those structs out into a separate
typespackage - which solves the issue, but I don't like that the code isn't co-located:Is there an alternative approach I can use? Maybe either with the
replace-typesorpackages? Sorry, fairly new to mockery, and Go in general. Any help here would be great.Beta Was this translation helpful? Give feedback.
All reactions