diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-10-27 12:58:00 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-10-28 10:10:47 +0200 |
commit | 8f5c7b0fc2b273e55b2116ddece21ac2c19fa863 (patch) | |
tree | 7f12c091b7ec63b2953695cee3f9be3685d4373d /yarns/100-happy.yarn | |
parent | cc2d1b21e67643e237d968793d31b7b9437a1640 (diff) | |
download | muck-poc-8f5c7b0fc2b273e55b2116ddece21ac2c19fa863.tar.gz |
Add: HTTP API, with scenario tests
Diffstat (limited to 'yarns/100-happy.yarn')
-rw-r--r-- | yarns/100-happy.yarn | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/yarns/100-happy.yarn b/yarns/100-happy.yarn new file mode 100644 index 0000000..dc6f6c1 --- /dev/null +++ b/yarns/100-happy.yarn @@ -0,0 +1,97 @@ +# A happy path scenario + +This scenario does some basic resource management via the Muck API. + + SCENARIO Muck + +Start Muck. This also sets up access to it for the user by getting an +access token, which will be used for all requests. + + GIVEN a running Muck + +Create a simple resource. Remember its id. + + WHEN user makes request POST /res with body { "foo": "bar" } + THEN status code is 201 + THEN remember resource id as ID + THEN remember resource revision as REV1 + +Retrieve the resource. + + WHEN user makes request GET /res with header "Muck-Id: ${ID}" + THEN status code is 200 + THEN response body is { "foo": "bar" } + THEN response has header "Muck-Id: ${ID}" + THEN response has header "Muck-Revision: ${REV1}" + +Update the resource. + + WHEN user makes request PUT /res with header "Muck-Id: ${ID}" and + ... header "Muck-Revision: wrong" and + ... body { "foo": "foobar" } + THEN status code is 400 + + WHEN user makes request PUT /res with header "Muck-Id: ${ID}" and + ... header "Muck-Revision: ${REV1}" and + ... body { "foo": "foobar" } + THEN status code is 200 + THEN remember resource revision as REV2 + +Check the resource has been updated. + + WHEN user makes request GET /res with header "Muck-Id: ${ID}" + THEN status code is 200 + THEN response body is { "foo": "foobar" } + THEN response has header "Muck-Id: ${ID}" + THEN response has header "Muck-Revision: ${REV2}" + +Restart Muck. The resource should still exist. + + WHEN Muck is restarted + WHEN user makes request GET /res with header "Muck-Id: ${ID}" + THEN status code is 200 + THEN response body is { "foo": "foobar" } + THEN response has header "Muck-Id: ${ID}" + THEN response has header "Muck-Revision: ${REV2}" + +Search for the resource. First with a condition that is no longer +true. + + WHEN user makes request GET /search with body + ... { + ... "cond": [ + ... {"where": "data", "field": "foo", "pattern": "bar", "op": "=="} + ... ] + ... } + THEN status code is 200 + THEN response body is {"resources": []} + +Now search for the correct value. + + WHEN user makes request GET /search with body + ... { + ... "cond": [ + ... {"where": "data", "field": "foo", "pattern": "foobar", + ... "op": "=="} + ... ] + ... } + THEN status code is 200 + THEN response body is {"resources": ["${ID}"]} + +Delete the resource. + + WHEN user makes request DELETE /res with header "Muck-Id: ${ID}" + THEN status code is 200 + + WHEN user makes request GET /res with header "Muck-Id: ${ID}" + THEN status code is 404 + +Restart Muck again. The resource should not exist. + + WHEN Muck is restarted + WHEN user makes request GET /res with header "Muck-Id: ${ID}" + THEN status code is 404 + +All done. + + FINALLY Muck is stopped |