Open tinchogob opened 10 years ago
I am thinking of making an attempt to implement this. Any initial thoughts or example codes? My main concern is that query() is written to fail via exception if the query params do not match, so if I modify this behaviour it will be a breaking change. I was considering using a different verb, say querySet() or queryAlt() or something better, so that I dont have to worry about backwards compatability. For example:
Handler1 = mock.get("/path1")
.persist()
.querySet({ a: 1 })
.reply(200, response1)
Handler2 = mock.get("/path1")
.persist()
.querySet({ a: 2 })
.reply(200, response2)
Without implementing I assume that in querySet I will need to do a deep comparison of actual and expected query params and either respond, or call next(). Open question is what to do if none of the querySet's match? Is it possible to abort and return nothing? is a 500 more appropriate? Maybe a way to specify the default behaviour:
HandlerDefault = mock.get("/path1")
.persist()
.queryElse()
.reply(defaultResponseStatus, defaultResponse)
Thoughts?
Support to mock an url and reply different things acording to the query.