I\'m having hard times writing unit tests in Go due to external libraries which don\'t expose an interface (therefore not mockable) but only pure functions. Even big ones like G
IMO this is a super common solution and strikes a good balance between maintainability and testability.
The way I think of this is that your code is programming to an interface, and there just happens to be two implementations:
With this approach, a stub can only verify up to your service and its dependencies boundary along the contract of the interface, it assures very little or nothing about your components collaboration/integration with the library that's being stubbed. In my experiences this approach works awesome and is my personal preference. I have found it to be important though to have 1 or 2 higher level tests making sure that your component can successfully initialize and interact with the "prod" version of the library.
Plug:
I've written about this exact issue https://medium.com/dm03514-tech-blog/you-are-going-to-need-it-using-interfaces-and-dependency-injection-to-future-proof-your-designs-2cf6f58db192