Thanks for the response Ian. My apologies for a delayed response (inline).
On Friday, December 13, 2019 at 6:11:20 AM UTC-8, Ian Davis wrote:
>
> On Thu, 12 Dec 2019, at 10:27 PM, karth...@gmail.com wrote:
>
> Specifically, I couldn't find how to partially mock the struct. Most
> suggestions rev
On Thu, 12 Dec 2019, at 10:27 PM, karthik3...@gmail.com wrote:
> Specifically, I couldn't find how to partially mock the `struct`. Most
> suggestions revolve around breaking such `struct`s but in this case, the
> `struct` is already at its bare minimum. It seems like a fair ask to not
> break th
I face similar problems in a lot of production Go code which I write. I do
have an answer for this, but it's not pretty. Your code would look
something like this:
type ResourceGetter interface {
GetResource(id string) (*Resource, error)
}
type ResourceManagerImpl struct {
rg ResourceGetter
I am having trouble writing unit tests in Go for a rather common
use-case/pattern.
Imagine, if you will, something like this:
package main
type Resource struct {
name string}
type ResourceManager interface {
GetResource(id string) (*Resource, error)
GetAllResources() ([]*Resour