Skip to content

Commit c2d60bb

Browse files
committedAug 3, 2020
Use yaml for declaration language
1 parent 9fb0ecb commit c2d60bb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+10150
-3555
lines changed
 

‎README.md

+32-31
Original file line numberDiff line numberDiff line change
@@ -7,48 +7,49 @@ A cli and library for declaring what how an API is expected to behave and checki
77

88
## Usage
99

10-
Describe how you expect an API to behave (currently in TOML)
10+
Describe how you expect an API to behave (currently in YAML)
1111

1212
Variables can be set from the command-line with `-var` e.g. `-var host=<address>`.
1313
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)
1515

1616
```
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"]
2928
```
3029
State what you expect the API to do with this input.
3130
```
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"]
3537
```
3638

3739
Steps from the same file are run in order and results from previous steps can be used
3840
e.g. `json .create_a_thing "id"` returns the value from the `id` key of the json response from the `create_a_thing` step.
3941
```
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"
5253
```
5354

5455
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.
6465

6566
In another terminal run the example hypothesis.
6667
```
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
6869
```
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.
7071

‎examples/crud.toml

-54
This file was deleted.

0 commit comments

Comments
 (0)
Please sign in to comment.