Skip to content

Commit c6238f7

Browse files
committed
✅ add error tests
1 parent d23fa85 commit c6238f7

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

runn-e2e/runbooks/test.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,15 @@ steps:
1616
post:
1717
include:
1818
path: test_post.yml
19+
postError:
20+
include:
21+
path: test_post_error.yml
1922
comment:
2023
include:
2124
path: test_comment.yml
25+
commentError:
26+
include:
27+
path: test_comment_error.yml
2228
profile:
2329
include:
2430
path: test_profile.yml
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
desc: "comment endpoint error tests"
2+
runners:
3+
req:
4+
endpoint: http://localhost:3000
5+
vars:
6+
duplicateCommentId: 1
7+
if: included
8+
steps:
9+
postCommentDuplicateIdError:
10+
desc: "Failed due to duplicate ID"
11+
req:
12+
/comments:
13+
post:
14+
body:
15+
application/json:
16+
id: "{{ vars.duplicateCommentId }}"
17+
text: "new comment"
18+
post_id: "{{ vars.postId }}"
19+
test: |
20+
// Status code must be 409.
21+
current.res.status == 409
22+
getCommentNotFoundError:
23+
desc: "Post is not found"
24+
req:
25+
/comments/999999:
26+
get:
27+
body:
28+
application/json: null
29+
test: |
30+
// Status code must be 404.
31+
current.res.status == 404

runn-e2e/runbooks/test_post_error.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
desc: "post endpoint error tests"
2+
runners:
3+
req:
4+
endpoint: http://localhost:3000
5+
vars:
6+
duplicatePostId: "01J7BAKH37HPG116ZRRFKHBDGB"
7+
if: included
8+
steps:
9+
postPostDuplicateIdError:
10+
desc: "Failed due to duplicate ID"
11+
req:
12+
/posts:
13+
post:
14+
body:
15+
application/json:
16+
id: "{{ vars.duplicatePostId }}"
17+
title: "new post"
18+
views: 0
19+
test: |
20+
// Status code must be 409.
21+
current.res.status == 409
22+
getPostNotFoundError:
23+
desc: "Comment is not found"
24+
req:
25+
/posts/notfound:
26+
get:
27+
body:
28+
application/json: null
29+
test: |
30+
// Status code must be 404.
31+
current.res.status == 404

0 commit comments

Comments
 (0)