diff --git a/pull_request_test.go b/pull_request_test.go new file mode 100644 index 00000000..609a27e7 --- /dev/null +++ b/pull_request_test.go @@ -0,0 +1,41 @@ +package api + +import ( + "encoding/json" + "testing" +) + +func TestPullRequest_ChecksStatus(t *testing.T) { + pr := PullRequest{} + payload := ` + { "commits": { "nodes": [{ "commit": { + "statusCheckRollup": { + "contexts": { + "nodes": [ + { "state": "SUCCESS" }, + { "state": "PENDING" }, + { "state": "FAILURE" }, + { "status": "IN_PROGRESS", + "conclusion": null }, + { "status": "COMPLETED", + "conclusion": "SUCCESS" }, + { "status": "COMPLETED", + "conclusion": "FAILURE" }, + { "status": "COMPLETED", + "conclusion": "ACTION_REQUIRED" }, + { "status": "COMPLETED", + "conclusion": "STALE" } + ] + } + } + } }] } } + ` + err := json.Unmarshal([]byte(payload), &pr) + eq(t, err, nil) + + checks := pr.ChecksStatus() + eq(t, checks.Total, 8) + eq(t, checks.Pending, 3) + eq(t, checks.Failing, 3) + eq(t, checks.Passing, 2) +} diff --git a/share_history (2).xml b/share_history (2).xml new file mode 100644 index 00000000..84a00827 --- /dev/null +++ b/share_history (2).xml @@ -0,0 +1 @@ + \ No newline at end of file