(t *testing.T)
| 117 | } |
| 118 | |
| 119 | func TestTemplateManagerSelect(t *testing.T) { |
| 120 | tests := []struct { |
| 121 | name string |
| 122 | isPR bool |
| 123 | templateName string |
| 124 | wantTemplate Template |
| 125 | wantErr bool |
| 126 | errMsg string |
| 127 | httpStubs func(*httpmock.Registry) |
| 128 | }{ |
| 129 | { |
| 130 | name: "no templates found", |
| 131 | templateName: "Bug report", |
| 132 | httpStubs: func(reg *httpmock.Registry) { |
| 133 | reg.Register( |
| 134 | httpmock.GraphQL(`query IssueTemplates\b`), |
| 135 | httpmock.StringResponse(`{"data":{"repository":{"issueTemplates":[]}}}`), |
| 136 | ) |
| 137 | }, |
| 138 | wantErr: true, |
| 139 | errMsg: "no templates found", |
| 140 | }, |
| 141 | { |
| 142 | name: "no matching templates found", |
| 143 | templateName: "Unknown report", |
| 144 | httpStubs: func(reg *httpmock.Registry) { |
| 145 | reg.Register( |
| 146 | httpmock.GraphQL(`query IssueTemplates\b`), |
| 147 | httpmock.StringResponse(` |
| 148 | { "data": { "repository": { "issueTemplates": [ |
| 149 | { "name": "Bug report", "body": "I found a problem" }, |
| 150 | { "name": "Feature request", "body": "I need a feature" } |
| 151 | ] } } }`), |
| 152 | ) |
| 153 | }, |
| 154 | wantErr: true, |
| 155 | errMsg: `template "Unknown report" not found`, |
| 156 | }, |
| 157 | { |
| 158 | name: "matching issue template found", |
| 159 | templateName: "Bug report", |
| 160 | httpStubs: func(reg *httpmock.Registry) { |
| 161 | reg.Register( |
| 162 | httpmock.GraphQL(`query IssueTemplates\b`), |
| 163 | httpmock.StringResponse(` |
| 164 | { "data": { "repository": { "issueTemplates": [ |
| 165 | { "name": "Bug report", "body": "I found a problem" }, |
| 166 | { "name": "Feature request", "body": "I need a feature" } |
| 167 | ] } } }`), |
| 168 | ) |
| 169 | }, |
| 170 | wantTemplate: &issueTemplate{ |
| 171 | Gname: "Bug report", |
| 172 | Gbody: "I found a problem", |
| 173 | }, |
| 174 | }, |
| 175 | { |
| 176 | name: "matching pull request template found", |
nothing calls this directly
no test coverage detected