-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapitest.yml
237 lines (229 loc) · 4.71 KB
/
apitest.yml
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
environment:
vars:
host: http://localhost:8080
api: "http://localhost:8080/api"
headers:
Content-Type: application/json
requests:
# CREATE
- name: POST new genre
url: "{{api}}/genres"
method: post
body:
name: Test
expect:
status: 201
values:
.name: Test
set:
- var: genre_id
from: .id
- var: genre_name
from: .name
- name: POST new series
url: "{{api}}/series"
method: post
body:
id: NG-ENG
name: Super Awesome Series
plannedVolumes: 2
bookTourEvents: 10
expect:
status: 201
values:
.id: NG-ENG
set:
- var: series_id
from: .id
- name: POST new author
url: "{{api}}/authors"
method: post
body:
id: UC101
firstName: Uchenna
lastName: Ofoma
birthDay: 2022-07-16
country: Nigeria
expect:
status: 201
values:
.id: UC101
set:
- var: author_id
from: .id
- name: POST new book
url: "{{api}}/books"
method: post
body:
id: NG200
title: Amazing Book
comment: This book is really cool!!!
volume: 2
genres:
- "{{genre_id}}"
series:
- "{{series_id}}"
authors:
- "{{author_id}}"
expect:
status: 201
values:
.id: NG200
.authors.[0].id: UC101 # "{{author_id}}"
.genres.[0]: Test # "{{genre_name}}"
.series.[0].id: NG-ENG # "{{series_id}}"
set:
- var: book_id
from: .id
# READ
- name: GET all genres
url: "{{api}}/genres"
method: get
expect:
status: 200
values:
.[0].name:
exists: true
- name: GET all series
url: "{{api}}/series"
method: get
expect:
status: 200
values:
.[0].id:
exists: true
- name: GET all authors
url: "{{api}}/authors"
method: get
expect:
status: 200
values:
.[0].id:
exists: true
- name: GET all books
url: "{{api}}/books"
method: get
expect:
status: 200
values:
.[0].id:
exists: true
# READ (BY ID)
- name: GET genre by id
url: "{{api}}/genres/{{genre_id}}"
method: get
expect:
status: 200
values:
.id:
exists: true
- name: GET series by id
url: "{{api}}/series/{{series_id}}"
method: get
expect:
status: 200
values:
.id:
exists: true
- name: GET author by id
url: "{{api}}/authors/{{author_id}}"
method: get
expect:
status: 200
values:
.id:
exists: true
- name: GET author by id
url: "{{api}}/books/{{book_id}}"
method: get
expect:
status: 200
values:
.id:
exists: true
.authors.[0].id: UC101 # "{{author_id}}"
.genres.[0]: Test # "{{genre_name}}"
.series.[0].id: NG-ENG # "{{series_id}}"
# READ (BY ID) (INEXISTENT)
- name: GET (inexistent) genre by id
url: "{{api}}/genres/0"
method: get
expect:
status: 404
- name: GET (inexistent) series by id
url: "{{api}}/series/inexistent"
method: get
expect:
status: 404
- name: GET (inexistent) author by id
url: "{{api}}/authors/inexistent"
method: get
expect:
status: 404
- name: GET (inexistent) book by id
url: "{{api}}/books/inexistent"
method: get
expect:
status: 404
# UPDATE
- name: PUT genre
url: "{{api}}/genres/{{genre_id}}"
method: put
body:
name: Changed Test
expect:
status: 200
values:
.name: Changed Test
- name: PUT series
url: "{{api}}/series/{{series_id}}"
method: put
body:
plannedVolumes: 5
bookTourEvents: 2
expect:
status: 200
values:
.plannedVolumes: 5
.bookTourEvents: 2
.id:
exists: true
- name: PUT author
url: "{{api}}/authors/{{author_id}}"
method: put
body:
firstName: Adophilus
expect:
status: 200
values:
.firstName: Adophilus
- name: PUT book
url: "{{api}}/books/{{book_id}}"
method: put
body:
comment: This comment was updated
expect:
status: 200
values:
.comment: This comment was updated
# DELETE
- name: DELETE genre
url: "{{api}}/genres/{{genre_id}}"
method: delete
expect:
status: 410
- name: DELETE series
url: "{{api}}/series/{{series_id}}"
method: delete
expect:
status: 410
- name: DELETE author
url: "{{api}}/authors/{{author_id}}"
method: delete
expect:
status: 410
- name: DELETE book
url: "{{api}}/books/{{book_id}}"
method: delete
expect:
status: 410