I'm writing some kind of a recursive parser. The simplest form is:
- Take
all links
fromfirst link
's page body - Repeat the first step for each link
So now I want to test it. The problem is I can't figure out the best way to mock all these pages. I use http
package and I already have some tests written using httptest
package (via httptest.NewServer
). But it seems to be no use for my task now. I guess the best way is to use http.Client
with custom Transport
struct, but it's lots of boilerplate and additional smelly code. Is there a more elegant way to do this?