summaryrefslogtreecommitdiff
path: root/muck.md
blob: 2c58c48f4d9e4b582b5dcaf76fa20d659181aa46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
---
title: Muck acceptance tests
author: Lars Wirzenius / The Ick project
...

Introduction
=============================================================================

Muck is a persistent in-memory JSON store with an HTTP API and
advanced access control using signed JWT access tokens. This document
presents its automated acceptance tests, using a (for now
hypothetical) language similar to the Gherkin language implemented by
Cucumber, called Fable.

A happy path scenario
=============================================================================

This scenario does some basic resource management via the Muck API.

Start Muck. This also sets up access to it for the user by getting an
access token, which will be used for all requests.

```fable
given a running Muck
```

Check server status.

```fable
then there are no resources in Muck
```

Create a simple resource. Remember its id.

```fable
given I am tomjon
when I create a resource {"foo": "bar"}
then there is 1 resource in Muck
and remember the resource id as ID
and remember the resource revision as REV1
```

Retrieve the resource.

```fable
when I fetch resource ID
then I get {"foo": "bar"}
and it is mine
and it has revision REV1
```

Make sure another user can't retreive, update, or delete the resource.

```fable
given I am verence
when I fetch resource ID
then it doesn't exist

when I update ID, revision REV1, with {"foo": "somethingelse"}
then it doesn't exist

when I delete  ID
then it doesn't exist
```

Update the resource.

```fable
given I am tomjon
when I update ID, revision wrong, with {"foo": "somethingelse"}
then it doesnt't work

when I update ID, revision REV1, with {"foo": "somethingelse"}
then it works
and remember the resource revision as REV2
```

Check the resource has been updated.

```fable
when I fetch resource ID
then I get {"foo": "somethingelse"}
and it is mine
and it has revision REV2
```

Restart Muck. The resource should still exist.

```fable
when Muck is restarted
and I fetch resource ID
then I get {"foo": "somethingelse"}
and it is mine
and it has revision REV2
```

Search for the resource. First with a condition that is no longer
true.

```fable
when I search for foo being bar
then there are no matches
```

Now search for the correct value.

```fable
when I search for foo being somethingelse
then I only get resource ID
```

Delete the resource.

```fable
when I delete ID
then it works
```


```fable
when I fetch resource ID
then it doesn't exist
```

Restart Muck again. The resource should not exist.

```fable
when Muck is restarted
and I fetch resource ID
then it doesn't exist
```

All done.