MCPcopy Index your code
hub / github.com/google/go-github / TestChecksService_ListCheckRunsForRef

Function TestChecksService_ListCheckRunsForRef

github/checks_test.go:309–379  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

307}
308
309func TestChecksService_ListCheckRunsForRef(t *testing.T) {
310 t.Parallel()
311 client, mux, _ := setup(t)
312
313 mux.HandleFunc("/repos/o/r/commits/master/check-runs", func(w http.ResponseWriter, r *http.Request) {
314 testMethod(t, r, "GET")
315 testHeader(t, r, "Accept", mediaTypeCheckRunsPreview)
316 testFormValues(t, r, values{
317 "check_name": "testing",
318 "page": "1",
319 "status": "completed",
320 "filter": "all",
321 "app_id": "1",
322 })
323 fmt.Fprint(w, `{"total_count":1,
324 "check_runs": [{
325 "id": 1,
326 "head_sha": "deadbeef",
327 "status": "completed",
328 "conclusion": "neutral",
329 "started_at": "2018-05-04T01:14:52Z",
330 "completed_at": "2018-05-04T01:14:52Z",
331 "app": {
332 "id": 1}}]}`,
333 )
334 })
335
336 opt := &ListCheckRunsOptions{
337 CheckName: Ptr("testing"),
338 Status: Ptr("completed"),
339 Filter: Ptr("all"),
340 AppID: Ptr(int64(1)),
341 ListOptions: ListOptions{Page: 1},
342 }
343 ctx := t.Context()
344 checkRuns, _, err := client.Checks.ListCheckRunsForRef(ctx, "o", "r", "master", opt)
345 if err != nil {
346 t.Errorf("Checks.ListCheckRunsForRef return error: %v", err)
347 }
348 startedAt, _ := time.Parse(time.RFC3339, "2018-05-04T01:14:52Z")
349 want := &ListCheckRunsResults{
350 Total: Ptr(1),
351 CheckRuns: []*CheckRun{{
352 ID: Ptr(int64(1)),
353 Status: Ptr("completed"),
354 StartedAt: &Timestamp{startedAt},
355 CompletedAt: &Timestamp{startedAt},
356 Conclusion: Ptr("neutral"),
357 HeadSHA: Ptr("deadbeef"),
358 App: &App{ID: Ptr(int64(1))},
359 }},
360 }
361
362 if !cmp.Equal(checkRuns, want) {
363 t.Errorf("Checks.ListCheckRunsForRef returned %+v, want %+v", checkRuns, want)
364 }
365
366 const methodName = "ListCheckRunsForRef"

Callers

nothing calls this directly

Calls 9

testMethodFunction · 0.85
testHeaderFunction · 0.85
testFormValuesFunction · 0.85
testBadOptionsFunction · 0.85
ListCheckRunsForRefMethod · 0.80
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…