I am unit-testing client code using ghttp (gomega) where I have N paths, path1, path2 to pathN. I use server.RouteToHandler().
I also have a requirement that 2nd time the same method and path is called, I need to have a different response. I could have used AppendHandlers(), but then the order might also not be the same every iteration.
Calls could be in the following order
- path1, path2, path3, path1, path2, path3
- path1, path1, path2, path3, path2, path3
server.RouteToHandler("POST", path1,
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", path1),
ghttp.RespondWithJSONEncoded(httpStatusCreatedCode, createResp1),
))
server.RouteToHandler("POST", path2,
ghttp.CombineHandlers(
ghttp.VerifyRequest("POST", path2),
ghttp.RespondWithJSONEncoded(httpStatusCreatedCode, createResp2),
))
How do I achieve this?
Thanks, /M