Sessions
Send an X-Mock-Session header to get your own copy of the data. Tests that run at the same time then never see each other’s changes:
curl -X POST localhost:4010/openapi/pets \ -H "X-Mock-Session: test-1" -H "Content-Type: application/json" \ -d '{"name":"Biscuit"}'
curl localhost:4010/openapi/pets -H "X-Mock-Session: test-1" # has Biscuitcurl localhost:4010/openapi/pets # does not- A session starts as a copy of the seed data, made when it first writes.
- Requests without the header share the default data.
- The control endpoints follow the header too: a reset or a read of the state with
X-Mock-Sessionworks on that session only.
Any value works as a session id. A test’s own name is a good one.