TheInkedEngineer/Espresso-Martini

Add the possibility to receive a different answer for the same request

Closed this issue · 0 comments

Two scenarios that are hard/impossible to test with the current version of the library are:

  1. Error then recover -- get an error on the first try, but pass on the second (or later).
  2. Polling -- continuously query an endpoint until the status of the response changes.

These two scenarios are similar as they both behave with the same concept -- Different response on the nth try.

To enable support for these two scenarios:

  1. The library must allow each network exchange to provide more than open response object
  2. The mock server should track how many requests where made to each endpoint
  3. When a request is received the mock server will return the min(numberOfRequest, arrayOfResponses.count -1)

This change won't break the public interface as it can keep the old initialiser and automatically transform that to an array of 1 element, and then add a new initialiser that takes it an array of responses.

The CI will be a bigger challenge, but in order to not break it, the decoding can be done manually and it can check whether the top object is an array or not, and behave accordingly.