Skip to content

Commit a3b9772

Browse files
committed
test: rewrite integration tests to use hurl
Fix #40
1 parent cd71fb1 commit a3b9772

File tree

3 files changed

+76
-61
lines changed

3 files changed

+76
-61
lines changed

.gitignore

-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1 @@
11
node_modules/
2-
3-
# RobotFramework reports
4-
tests/log.html
5-
tests/output.xml
6-
tests/report.html

tests/crud.hurl

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#
2+
# Tests for basic CRUD operations
3+
#
4+
# How to run:
5+
# hurl --variable SERVER_URL=http://127.0.0.1:3000 crud.hurl --test
6+
#
7+
# See also: https://hurl.dev and https://github.com/Orange-OpenSource/hurl
8+
#
9+
10+
11+
# POST should create an object
12+
POST {{ SERVER_URL }}/v1/categories
13+
{
14+
"name": "Sport",
15+
"slug": "sport",
16+
"user_id": 1
17+
}
18+
HTTP 204
19+
20+
# ensures that it was created
21+
GET {{ SERVER_URL }}/v1/categories/count
22+
HTTP 200
23+
[Asserts]
24+
jsonpath "$.counter" == 1
25+
26+
27+
# GET should return a value
28+
GET {{ SERVER_URL }}/v1/categories/1
29+
HTTP 200
30+
[Asserts]
31+
header "Content-Type" == "application/json; charset=utf-8"
32+
jsonpath "$.id" == 1
33+
jsonpath "$.name" == "Sport"
34+
jsonpath "$.name_ru" == null
35+
jsonpath "$.slug" == "sport"
36+
37+
38+
# GET should return a list of values
39+
GET {{ SERVER_URL }}/v1/categories
40+
HTTP 200
41+
[Asserts]
42+
header "Content-Type" == "application/json; charset=utf-8"
43+
jsonpath "$" count == 1
44+
jsonpath "$[0].id" == 1
45+
jsonpath "$[0].name" == "Sport"
46+
jsonpath "$[0].name_ru" == null
47+
jsonpath "$[0].slug" == "sport"
48+
49+
50+
# PUT should update an object
51+
PUT {{ SERVER_URL }}/v1/categories/1
52+
{
53+
"name": "Fauna",
54+
"name_ru": "Фауна",
55+
"slug": "fauna",
56+
"user_id": 1
57+
}
58+
HTTP 204
59+
60+
# ensures that it was updated
61+
GET {{ SERVER_URL }}/v1/categories/1
62+
HTTP 200
63+
[Asserts]
64+
header "Content-Type" == "application/json; charset=utf-8"
65+
jsonpath "$.name" == "Fauna"
66+
jsonpath "$.name_ru" == "Фауна"
67+
jsonpath "$.slug" == "fauna"
68+
69+
70+
# DELETE should remove an object
71+
DELETE {{ SERVER_URL }}/v1/categories/1
72+
HTTP 204
73+
74+
# ensures that it was removed
75+
GET {{ SERVER_URL }}/v1/categories/1
76+
HTTP 404

tests/crud.robot

-56
This file was deleted.

0 commit comments

Comments
 (0)