A very popular question people ask when working with Go and HTTP clients is how
to test the code with go test. You will see many mentions of
interfaces,
test doubles
(stubs, mocks, fakes, etc.),
httptest, and so on.
I had a similar problem but it was like this: a function in module A was doing
some work on the results returned by a function in module B. In other words,
module A was depending on module B. Module B is expected to have its own tests,
which must not be repeated in the tests written for module A; why duplicate
the effort? How could I test module A without also testing module B in the
tests written for module A?
Read more …