| 276 | } |
| 277 | |
| 278 | func TestRunClose_Me(t *testing.T) { |
| 279 | defer gock.Off() |
| 280 | // gock.Observe(gock.DumpRequest) |
| 281 | |
| 282 | // get viewer ID |
| 283 | gock.New("https://api.github.com"). |
| 284 | Post("/graphql"). |
| 285 | MatchType("json"). |
| 286 | JSON(map[string]interface{}{ |
| 287 | "query": "query ViewerOwner.*", |
| 288 | }). |
| 289 | Reply(200). |
| 290 | JSON(map[string]interface{}{ |
| 291 | "data": map[string]interface{}{ |
| 292 | "viewer": map[string]interface{}{ |
| 293 | "id": "an ID", |
| 294 | }, |
| 295 | }, |
| 296 | }) |
| 297 | |
| 298 | // get viewer project ID |
| 299 | gock.New("https://api.github.com"). |
| 300 | Post("/graphql"). |
| 301 | MatchType("json"). |
| 302 | JSON(map[string]interface{}{ |
| 303 | "query": "query ViewerProject.*", |
| 304 | "variables": map[string]interface{}{ |
| 305 | "number": 1, |
| 306 | "firstItems": 0, |
| 307 | "afterItems": nil, |
| 308 | "firstFields": 0, |
| 309 | "afterFields": nil, |
| 310 | }, |
| 311 | }). |
| 312 | Reply(200). |
| 313 | JSON(map[string]interface{}{ |
| 314 | "data": map[string]interface{}{ |
| 315 | "viewer": map[string]interface{}{ |
| 316 | "projectV2": map[string]string{ |
| 317 | "id": "an ID", |
| 318 | }, |
| 319 | }, |
| 320 | }, |
| 321 | }) |
| 322 | |
| 323 | // close project |
| 324 | gock.New("https://api.github.com"). |
| 325 | Post("/graphql"). |
| 326 | BodyString(`{"query":"mutation CloseProjectV2.*"variables":{"afterFields":null,"afterItems":null,"firstFields":0,"firstItems":0,"input":{"projectId":"an ID","closed":true}}}`). |
| 327 | Reply(200). |
| 328 | JSON(map[string]interface{}{ |
| 329 | "data": map[string]interface{}{ |
| 330 | "updateProjectV2": map[string]interface{}{ |
| 331 | "projectV2": map[string]interface{}{ |
| 332 | "title": "a title", |
| 333 | "url": "http://a-url.com", |
| 334 | "owner": map[string]string{ |
| 335 | "login": "me", |