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

Function TestValidatePRInfo

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

Source from the content-addressed store, hash-verified

26)
27
28func TestValidatePRInfo(t *testing.T) {
29 testCases := []struct {
30 name string
31 data string
32 wantErr bool
33 }{
34 {
35 name: "valid GitHub PR",
36 data: `{
37 "platform": "github",
38 "type": "pull_request",
39 "number": "123",
40 "url": "https://github.com/owner/repo/pull/123",
41 "title": "Add new feature",
42 "description": "This PR adds a new feature",
43 "source_branch": "feature-branch",
44 "target_branch": "main",
45 "author": "username"
46 }`,
47 wantErr: false,
48 },
49 {
50 name: "valid GitLab MR minimal",
51 data: `{
52 "platform": "gitlab",
53 "type": "merge_request",
54 "number": "456",
55 "url": "https://gitlab.com/owner/repo/-/merge_requests/456"
56 }`,
57 wantErr: false,
58 },
59 {
60 name: "missing required field: platform",
61 data: `{
62 "type": "pull_request",
63 "number": "123",
64 "url": "https://github.com/owner/repo/pull/123"
65 }`,
66 wantErr: true,
67 },
68 {
69 name: "missing required field: url",
70 data: `{
71 "platform": "github",
72 "type": "pull_request",
73 "number": "123"
74 }`,
75 wantErr: true,
76 },
77 {
78 name: "invalid platform value",
79 data: `{
80 "platform": "bitbucket",
81 "type": "pull_request",
82 "number": "123",
83 "url": "https://bitbucket.org/owner/repo/pull/123"
84 }`,
85 wantErr: true,

Callers

nothing calls this directly

Calls 3

ValidatePRInfoFunction · 0.92
ErrorMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected