chargebee / chargebee-go

Go library for the Chargebee API.
https://apidocs.chargebee.com/docs/api?lang=go
MIT License
24 stars 23 forks source link

Interface for mocking in tests #6

Open kevinmichaelchen opened 5 years ago

kevinmichaelchen commented 5 years ago

It'd be nice if there were an interface for the Chargebee client, which provided all the various methods for interacting with the Chargebee SDK.

The Kubernetes Go SDK provides an interface called kubernetes.Interface, an actual implementation called kubernetes.Clientset, and a implementation for tests called fake.Clientset.

sanan-fataliyev commented 4 years ago

even though it would be nice for us - consumers, but it seems it's a popular antipattern in golang.

https://github.com/golang/go/wiki/CodeReviewComments#interfaces

Go interfaces generally belong in the package that uses values of the interface type, not the package that implements those values.

Do not define interfaces on the implementor side of an API "for mocking"; instead, design the API so that it can be tested using the public API of the real implementation.