MCPcopy Index your code
hub / github.com/cli/cli / TestChecksStatus_SummarisingStatusContexts

Function TestChecksStatus_SummarisingStatusContexts

api/pull_request_test.go:141–191  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

139}
140
141func TestChecksStatus_SummarisingStatusContexts(t *testing.T) {
142 t.Parallel()
143
144 tests := []struct {
145 name string
146 payload string
147 expectedChecksStatus PullRequestChecksStatus
148 }{
149 {
150 name: "EXPECTED is treated as Pending",
151 payload: singleStatusContextWithState("EXPECTED"),
152 expectedChecksStatus: PullRequestChecksStatus{Pending: 1, Total: 1},
153 },
154 {
155 name: "PENDING is treated as Pending",
156 payload: singleStatusContextWithState("PENDING"),
157 expectedChecksStatus: PullRequestChecksStatus{Pending: 1, Total: 1},
158 },
159 {
160 name: "SUCCESS is treated as Passing",
161 payload: singleStatusContextWithState("SUCCESS"),
162 expectedChecksStatus: PullRequestChecksStatus{Passing: 1, Total: 1},
163 },
164 {
165 name: "ERROR is treated as Failing",
166 payload: singleStatusContextWithState("ERROR"),
167 expectedChecksStatus: PullRequestChecksStatus{Failing: 1, Total: 1},
168 },
169 {
170 name: "FAILURE is treated as Failing",
171 payload: singleStatusContextWithState("FAILURE"),
172 expectedChecksStatus: PullRequestChecksStatus{Failing: 1, Total: 1},
173 },
174 {
175 name: "Unrecognized States are treated as Pending",
176 payload: singleStatusContextWithState("AnUnrecognizedStateJustForThisTest"),
177 expectedChecksStatus: PullRequestChecksStatus{Pending: 1, Total: 1},
178 },
179 }
180
181 for _, tt := range tests {
182 t.Run(tt.name, func(t *testing.T) {
183 t.Parallel()
184
185 var pr PullRequest
186 require.NoError(t, json.Unmarshal([]byte(tt.payload), &pr))
187
188 require.Equal(t, tt.expectedChecksStatus, pr.ChecksStatus())
189 })
190 }
191}
192
193func TestChecksStatus_SummarisingCheckRunsAndStatusContexts(t *testing.T) {
194 t.Parallel()

Callers

nothing calls this directly

Calls 4

ChecksStatusMethod · 0.95
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected