This repository was archived by the owner on Oct 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgist_comments
executable file
·115 lines (95 loc) · 2.41 KB
/
gist_comments
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
#! /usr/bin/env bash
# -author Giovanni Farfan B.
before_api() {
domain "api.github.com"
basePath "/gists/$( get gistId )/comments"
hd "User-Agent" "$( get appName )"
hd "Accept" "application/vnd.github.$( get apiVersion ).full+json"
hd "Content-Type" "application/vnd.github.$( get apiVersion ).full+json"
}
# ./gist_comments get_all
get_all() {
:
}
# ./gist_comments get_comment
get_comment() {
endpoint "/$( get commentId )"
}
before_post_comment() {
authMode BASIC
credential sample
}
# ./gist_comments post_comment
post_comment() {
body '{ "body": "shTTP-samples comment" }'
}
after_post_comment() {
areEquals "Unexpected status" "201" "$( getStatus )"
isNotNull "Comment ID not found" "$( getOutput id )"
put commentId '.id'
}
get_comments() {
:
}
# ./gist_comments patch_comment
patch_comment() {
authMode BASIC
credential sample
endpoint "/$( get commentId )"
body '{ "body": "'
# 5 times
body 0 '5t' 'Lorem ipsum '
# 150 bytes of size
body 0 '150s' 'Lorem ipsum '
body '" }'
}
after_patch_comment() {
areEquals "Unexpected status" "200" "$( getStatus )"
}
# ./gist_comments delete_comment --auth-basic sample
delete_comment() {
endpoint "/$( get commentId )"
}
after_delete_comment() {
areEquals "Unexpected status" "204" "$( getStatus )"
remove commentId
}
# ./gist_comments only_def
get_only_def() {
endpoint "/not_implemented_yet/$( get commentId )"
mockEnabled
mockOutput "{ \"column\": \"value\" }"
mockStatus 403
mockHeaders 'Expected-Header: 5134123123'
}
after_get_only_def() {
isNotNull "Column not found" "$( getOutput column )"
areEquals "Unexpected status" "403" "$( getStatus )"
areEquals "Unexpected header" "5134123123" "$( getHeader 'Expected-Header' )"
}
after_api() {
warn "Flow discard execution of this function"
}
before_flow() {
info "This will be executed before every flow call"
}
before_flow_comment() {
mainOpts --auth-basic sample
}
# ./gist_comments flow_comment
flow_comment() {
step post_comment
step get_comment
step patch_comment --auth-basic sample
step get_comment
step delete_comment --auth-basic sample
step get_only_def
}
after_flow_comment() {
info "This will be executed after 'flow_comment' call"
}
after_flow() {
info "This will be executed after every flow call"
}
# shellcheck disable=SC1091
. ../shttp