@@ -7,48 +7,49 @@ A cli and library for declaring what how an API is expected to behave and checki
7
7
8
8
## Usage
9
9
10
- Describe how you expect an API to behave (currently in TOML )
10
+ Describe how you expect an API to behave (currently in YAML )
11
11
12
12
Variables can be set from the command-line with ` -var ` e.g. ` -var host=<address> ` .
13
13
This can be done multiple times ` -var host=<address> -var token=<authToken> `
14
- [ examples/crud.toml ] ( /example/crud.toml )
14
+ [ examples/crud.yaml ] ( /example/crud.yaml )
15
15
16
16
```
17
- [create_a_thing]
18
- name = "Create a thing"
19
- uri = "{{ .host }}/things/"
20
- method = "POST"
21
- body = """
22
- {
23
- "hello": "world",
24
- "works": false
25
- }
26
- """
27
- [create_a_thing.headers]
28
- Authorization = ["Bearer sample_bearer_token"]
17
+ create_a_thing:
18
+ name: "Create a thing"
19
+ url: "{{ .host }}/things/"
20
+ method: "POST"
21
+ body: |
22
+ {
23
+ "hello": "world",
24
+ "works": false
25
+ }
26
+ headers:
27
+ Authorization: ["Bearer sample_bearer_token"]
29
28
```
30
29
State what you expect the API to do with this input.
31
30
```
32
- [create_a_thing.assert]
33
- [create_a_thing.assert.code]
34
- code = 200
31
+ assert:
32
+ response:
33
+ code: 200
34
+ body: '{"id": 0}'
35
+ headers:
36
+ Content-Type: ["application/json"]
35
37
```
36
38
37
39
Steps from the same file are run in order and results from previous steps can be used
38
40
e.g. ` json .create_a_thing "id" ` returns the value from the ` id ` key of the json response from the ` create_a_thing ` step.
39
41
```
40
- [read_a_thing]
41
- name = "Read a thing"
42
- uri = "{{ .host }}/things/${ json .create_a_thing `id` }"
43
- method = "GET"
44
- [read_a_thing.headers]
45
- Authorization = ["Bearer sample_bearer_token"]
46
-
47
- [read_a_thing.assert]
48
- [read_a_thing.assert.code]
49
- code = 200
50
- [read_a_thing.assert.jsonschema]
51
- ref = "examples/thing.json"
42
+ read_a_thing:
43
+ name: "Read a thing"
44
+ url: "{{ .host }}/things/${ json .create_a_thing `id` }"
45
+ method: "GET"
46
+ headers:
47
+ Authorization: ["Bearer sample_bearer_token"]
48
+ assert:
49
+ response:
50
+ code: 200
51
+ jsonschema:
52
+ ref: "examples/thing.json"
52
53
```
53
54
54
55
For a full example run you can pull down the repository and use the server used for tests to experiment.
@@ -64,7 +65,7 @@ This will output the port the test server is running on.
64
65
65
66
In another terminal run the example hypothesis.
66
67
```
67
- go run . -v -var host=<address from go test> examples/crud.toml
68
+ go run . -v -var host=<address from go test> examples/crud.yaml
68
69
```
69
- Try modifying [ examples/crud.toml ] ( /examples/crud.toml ) to make the run fail.
70
+ Try modifying [ examples/crud.yaml ] ( /examples/crud.yaml ) to make the run fail.
70
71
0 commit comments