1use mockito::{mock, Mock};
2
3pub fn mock_create_check_run() -> Mock {
4 mock("POST", "/repos/github/hello-world/check-runs")
5 .with_status(201)
6 .with_body(r#"
7 {
8 "id": 4,
9 "head_sha": "ce587453ced02b1526dfb4cb910479d431683101",
10 "node_id": "MDg6Q2hlY2tSdW40",
11 "external_id": "42",
12 "url": "https://api.github.com/repos/github/hello-world/check-runs/4",
13 "html_url": "https://github.com/github/hello-world/runs/4",
14 "details_url": "https://example.com",
15 "status": "in_progress",
16 "conclusion": null,
17 "started_at": "2018-05-04T01:14:52Z",
18 "completed_at": null,
19 "output": {
20 "title": "Mighty Readme report",
21 "summary": "There are 0 failures, 2 warnings, and 1 notice.",
22 "text": "You may have some misspelled words on lines 2 and 4. You also may want to add a section in your README about how to install your app.",
23 "annotations_count": 2,
24 "annotations_url": "https://api.github.com/repos/github/hello-world/check-runs/4/annotations"
25 },
26 "name": "mighty_readme",
27 "check_suite": {
28 "id": 5
29 },
30 "app": {
31 "id": 1,
32 "slug": "octoapp",
33 "node_id": "MDExOkludGVncmF0aW9uMQ==",
34 "owner": {
35 "login": "github",
36 "id": 1,
37 "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
38 "url": "https://api.github.com/orgs/github",
39 "repos_url": "https://api.github.com/orgs/github/repos",
40 "events_url": "https://api.github.com/orgs/github/events",
41 "avatar_url": "https://github.com/images/error/octocat_happy.gif",
42 "gravatar_id": "",
43 "html_url": "https://github.com/octocat",
44 "followers_url": "https://api.github.com/users/octocat/followers",
45 "following_url": "https://api.github.com/users/octocat/following{/other_user}",
46 "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
47 "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
48 "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
49 "organizations_url": "https://api.github.com/users/octocat/orgs",
50 "received_events_url": "https://api.github.com/users/octocat/received_events",
51 "type": "User",
52 "site_admin": true
53 },
54 "name": "Octocat App",
55 "description": "",
56 "external_url": "https://example.com",
57 "html_url": "https://github.com/apps/octoapp",
58 "created_at": "2017-07-08T16:18:44-04:00",
59 "updated_at": "2017-07-08T16:18:44-04:00",
60 "permissions": {
61 "metadata": "read",
62 "contents": "read",
63 "issues": "write",
64 "single_file": "write"
65 },
66 "events": [
67 "push",
68 "pull_request"
69 ]
70 },
71 "pull_requests": [
72 {
73 "url": "https://api.github.com/repos/github/hello-world/pulls/1",
74 "id": 1934,
75 "number": 3956,
76 "head": {
77 "ref": "say-hello",
78 "sha": "3dca65fa3e8d4b3da3f3d056c59aee1c50f41390",
79 "repo": {
80 "id": 526,
81 "url": "https://api.github.com/repos/github/hello-world",
82 "name": "hello-world"
83 }
84 },
85 "base": {
86 "ref": "master",
87 "sha": "e7fdf7640066d71ad16a86fbcbb9c6a10a18af4f",
88 "repo": {
89 "id": 526,
90 "url": "https://api.github.com/repos/github/hello-world",
91 "name": "hello-world"
92 }
93 }
94 }
95 ]
96 }
97 "#,
98 )
99 .create()
100}
101
102pub fn mock_list_check_runs_for_check_suite() -> Mock {
103 mock("GET", "/repos/github/hello-world/check-suites/5/check-runs").with_status(200).with_body(r#"
104 {
105 "total_count": 1,
106 "check_runs": [
107 {
108 "id": 4,
109 "head_sha": "ce587453ced02b1526dfb4cb910479d431683101",
110 "node_id": "MDg6Q2hlY2tSdW40",
111 "external_id": "",
112 "url": "https://api.github.com/repos/github/hello-world/check-runs/4",
113 "html_url": "https://github.com/github/hello-world/runs/4",
114 "details_url": "https://example.com",
115 "status": "completed",
116 "conclusion": "neutral",
117 "started_at": "2018-05-04T01:14:52Z",
118 "completed_at": "2018-05-04T01:14:52Z",
119 "output": {
120 "title": "Mighty Readme report",
121 "summary": "There are 0 failures, 2 warnings, and 1 notice.",
122 "text": "You may have some misspelled words on lines 2 and 4. You also may want to add a section in your README about how to install your app.",
123 "annotations_count": 2,
124 "annotations_url": "https://api.github.com/repos/github/hello-world/check-runs/4/annotations"
125 },
126 "name": "mighty_readme",
127 "check_suite": {
128 "id": 5
129 },
130 "app": {
131 "id": 1,
132 "slug": "octoapp",
133 "node_id": "MDExOkludGVncmF0aW9uMQ==",
134 "owner": {
135 "login": "github",
136 "id": 1,
137 "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
138 "url": "https://api.github.com/orgs/github",
139 "repos_url": "https://api.github.com/orgs/github/repos",
140 "events_url": "https://api.github.com/orgs/github/events",
141 "avatar_url": "https://github.com/images/error/octocat_happy.gif",
142 "gravatar_id": "",
143 "html_url": "https://github.com/octocat",
144 "followers_url": "https://api.github.com/users/octocat/followers",
145 "following_url": "https://api.github.com/users/octocat/following{/other_user}",
146 "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
147 "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
148 "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
149 "organizations_url": "https://api.github.com/users/octocat/orgs",
150 "received_events_url": "https://api.github.com/users/octocat/received_events",
151 "type": "User",
152 "site_admin": true
153 },
154 "name": "Octocat App",
155 "description": "",
156 "external_url": "https://example.com",
157 "html_url": "https://github.com/apps/octoapp",
158 "created_at": "2017-07-08T16:18:44-04:00",
159 "updated_at": "2017-07-08T16:18:44-04:00",
160 "permissions": {
161 "metadata": "read",
162 "contents": "read",
163 "issues": "write",
164 "single_file": "write"
165 },
166 "events": [
167 "push",
168 "pull_request"
169 ]
170 },
171 "pull_requests": [
172 {
173 "url": "https://api.github.com/repos/github/hello-world/pulls/1",
174 "id": 1934,
175 "number": 3956,
176 "head": {
177 "ref": "say-hello",
178 "sha": "3dca65fa3e8d4b3da3f3d056c59aee1c50f41390",
179 "repo": {
180 "id": 526,
181 "url": "https://api.github.com/repos/github/hello-world",
182 "name": "hello-world"
183 }
184 },
185 "base": {
186 "ref": "master",
187 "sha": "e7fdf7640066d71ad16a86fbcbb9c6a10a18af4f",
188 "repo": {
189 "id": 526,
190 "url": "https://api.github.com/repos/github/hello-world",
191 "name": "hello-world"
192 }
193 }
194 }
195 ]
196 }
197 ]
198 }
199 "#
200 ).create()
201}
202
203pub fn mock_update_check_run() -> Mock {
204 mock("PATCH", "/repos/github/hello-world/check-runs/4")
205 .with_status(200)
206 .with_body(r#"
207 {
208 "id": 4,
209 "head_sha": "ce587453ced02b1526dfb4cb910479d431683101",
210 "node_id": "MDg6Q2hlY2tSdW40",
211 "external_id": "",
212 "url": "https://api.github.com/repos/github/hello-world/check-runs/4",
213 "html_url": "https://github.com/github/hello-world/runs/4",
214 "details_url": "https://example.com",
215 "status": "completed",
216 "conclusion": "neutral",
217 "started_at": "2018-05-04T01:14:52Z",
218 "completed_at": "2018-05-04T01:14:52Z",
219 "output": {
220 "title": "Mighty Readme report",
221 "summary": "There are 0 failures, 2 warnings, and 1 notice.",
222 "text": "You may have some misspelled words on lines 2 and 4. You also may want to add a section in your README about how to install your app.",
223 "annotations_count": 2,
224 "annotations_url": "https://api.github.com/repos/github/hello-world/check-runs/4/annotations"
225 },
226 "name": "mighty_readme",
227 "check_suite": {
228 "id": 5
229 },
230 "app": {
231 "id": 1,
232 "slug": "octoapp",
233 "node_id": "MDExOkludGVncmF0aW9uMQ==",
234 "owner": {
235 "login": "github",
236 "id": 1,
237 "node_id": "MDEyOk9yZ2FuaXphdGlvbjE=",
238 "url": "https://api.github.com/orgs/github",
239 "repos_url": "https://api.github.com/orgs/github/repos",
240 "events_url": "https://api.github.com/orgs/github/events",
241 "avatar_url": "https://github.com/images/error/octocat_happy.gif",
242 "gravatar_id": "",
243 "html_url": "https://github.com/octocat",
244 "followers_url": "https://api.github.com/users/octocat/followers",
245 "following_url": "https://api.github.com/users/octocat/following{/other_user}",
246 "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
247 "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
248 "subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
249 "organizations_url": "https://api.github.com/users/octocat/orgs",
250 "received_events_url": "https://api.github.com/users/octocat/received_events",
251 "type": "User",
252 "site_admin": true
253 },
254 "name": "Octocat App",
255 "description": "",
256 "external_url": "https://example.com",
257 "html_url": "https://github.com/apps/octoapp",
258 "created_at": "2017-07-08T16:18:44-04:00",
259 "updated_at": "2017-07-08T16:18:44-04:00",
260 "permissions": {
261 "metadata": "read",
262 "contents": "read",
263 "issues": "write",
264 "single_file": "write"
265 },
266 "events": [
267 "push",
268 "pull_request"
269 ]
270 },
271 "pull_requests": [
272 {
273 "url": "https://api.github.com/repos/github/hello-world/pulls/1",
274 "id": 1934,
275 "number": 3956,
276 "head": {
277 "ref": "say-hello",
278 "sha": "3dca65fa3e8d4b3da3f3d056c59aee1c50f41390",
279 "repo": {
280 "id": 526,
281 "url": "https://api.github.com/repos/github/hello-world",
282 "name": "hello-world"
283 }
284 },
285 "base": {
286 "ref": "master",
287 "sha": "e7fdf7640066d71ad16a86fbcbb9c6a10a18af4f",
288 "repo": {
289 "id": 526,
290 "url": "https://api.github.com/repos/github/hello-world",
291 "name": "hello-world"
292 }
293 }
294 }
295 ]
296 }
297 "#,
298 )
299 .create()
300}