(t *testing.T)
| 88 | } |
| 89 | |
| 90 | func TestPullRequestFeatures(t *testing.T) { |
| 91 | tests := []struct { |
| 92 | name string |
| 93 | hostname string |
| 94 | queryResponse map[string]string |
| 95 | wantFeatures PullRequestFeatures |
| 96 | wantErr bool |
| 97 | }{ |
| 98 | { |
| 99 | name: "github.com with all features", |
| 100 | hostname: "github.com", |
| 101 | queryResponse: map[string]string{ |
| 102 | `query PullRequest_fields\b`: heredoc.Doc(` |
| 103 | { |
| 104 | "data": { |
| 105 | "PullRequest": { |
| 106 | "fields": [ |
| 107 | {"name": "isInMergeQueue"}, |
| 108 | {"name": "isMergeQueueEnabled"} |
| 109 | ] |
| 110 | }, |
| 111 | "StatusCheckRollupContextConnection": { |
| 112 | "fields": [ |
| 113 | {"name": "checkRunCount"}, |
| 114 | {"name": "checkRunCountsByState"}, |
| 115 | {"name": "statusContextCount"}, |
| 116 | {"name": "statusContextCountsByState"} |
| 117 | ] |
| 118 | } |
| 119 | } |
| 120 | }`), |
| 121 | `query PullRequest_fields2\b`: heredoc.Doc(` |
| 122 | { |
| 123 | "data": { |
| 124 | "WorkflowRun": { |
| 125 | "fields": [ |
| 126 | {"name": "event"} |
| 127 | ] |
| 128 | } |
| 129 | } |
| 130 | }`), |
| 131 | }, |
| 132 | wantFeatures: PullRequestFeatures{ |
| 133 | MergeQueue: true, |
| 134 | CheckRunAndStatusContextCounts: true, |
| 135 | CheckRunEvent: true, |
| 136 | }, |
| 137 | wantErr: false, |
| 138 | }, |
| 139 | { |
| 140 | name: "github.com with no merge queue", |
| 141 | hostname: "github.com", |
| 142 | queryResponse: map[string]string{ |
| 143 | `query PullRequest_fields\b`: heredoc.Doc(` |
| 144 | { |
| 145 | "data": { |
| 146 | "PullRequest": { |
| 147 | "fields": [] |
nothing calls this directly
no test coverage detected