MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / TestValidatePRInfoV1_2

Function TestValidatePRInfoV1_2

internal/prinfo/prinfo_test.go:188–264  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

186}
187
188func TestValidatePRInfoV1_2(t *testing.T) {
189 testCases := []struct {
190 name string
191 data string
192 wantErr bool
193 }{
194 {
195 name: "valid reviewer with requested and review_status",
196 data: `{
197 "platform": "github",
198 "type": "pull_request",
199 "number": "789",
200 "url": "https://github.com/owner/repo/pull/789",
201 "reviewers": [
202 {"login": "reviewer1", "type": "User", "requested": true, "review_status": "COMMENTED"},
203 {"login": "reviewer2", "type": "User", "requested": false, "review_status": "APPROVED"},
204 {"login": "coderabbitai", "type": "Bot", "requested": true}
205 ]
206 }`,
207 wantErr: false,
208 },
209 {
210 name: "reviewer missing required requested field fails validation",
211 data: `{
212 "platform": "github",
213 "type": "pull_request",
214 "number": "789",
215 "url": "https://github.com/owner/repo/pull/789",
216 "reviewers": [
217 {"login": "reviewer1", "type": "User"}
218 ]
219 }`,
220 wantErr: true,
221 },
222 {
223 name: "invalid review_status value",
224 data: `{
225 "platform": "github",
226 "type": "pull_request",
227 "number": "789",
228 "url": "https://github.com/owner/repo/pull/789",
229 "reviewers": [
230 {"login": "reviewer1", "type": "User", "review_status": "UNKNOWN_STATE"}
231 ]
232 }`,
233 wantErr: true,
234 },
235 {
236 name: "additional property in reviewer not allowed",
237 data: `{
238 "platform": "github",
239 "type": "pull_request",
240 "number": "789",
241 "url": "https://github.com/owner/repo/pull/789",
242 "reviewers": [
243 {"login": "reviewer1", "type": "User", "extra": "not allowed"}
244 ]
245 }`,

Callers

nothing calls this directly

Calls 3

ValidatePRInfoFunction · 0.92
ErrorMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected