(t *testing.T)
| 270 | } |
| 271 | |
| 272 | func TestRepositoryFeatures(t *testing.T) { |
| 273 | tests := []struct { |
| 274 | name string |
| 275 | hostname string |
| 276 | queryResponse map[string]string |
| 277 | wantFeatures RepositoryFeatures |
| 278 | wantErr bool |
| 279 | }{ |
| 280 | { |
| 281 | name: "github.com", |
| 282 | hostname: "github.com", |
| 283 | wantFeatures: RepositoryFeatures{ |
| 284 | PullRequestTemplateQuery: true, |
| 285 | VisibilityField: true, |
| 286 | AutoMerge: true, |
| 287 | }, |
| 288 | wantErr: false, |
| 289 | }, |
| 290 | { |
| 291 | name: "ghec data residency (ghe.com)", |
| 292 | hostname: "stampname.ghe.com", |
| 293 | wantFeatures: RepositoryFeatures{ |
| 294 | PullRequestTemplateQuery: true, |
| 295 | VisibilityField: true, |
| 296 | AutoMerge: true, |
| 297 | }, |
| 298 | wantErr: false, |
| 299 | }, |
| 300 | { |
| 301 | name: "GHE empty response", |
| 302 | hostname: "git.my.org", |
| 303 | queryResponse: map[string]string{ |
| 304 | `query Repository_fields\b`: `{"data": {}}`, |
| 305 | }, |
| 306 | wantFeatures: RepositoryFeatures{ |
| 307 | PullRequestTemplateQuery: false, |
| 308 | }, |
| 309 | wantErr: false, |
| 310 | }, |
| 311 | { |
| 312 | name: "GHE has pull request template query", |
| 313 | hostname: "git.my.org", |
| 314 | queryResponse: map[string]string{ |
| 315 | `query Repository_fields\b`: heredoc.Doc(` |
| 316 | { "data": { "Repository": { "fields": [ |
| 317 | {"name": "pullRequestTemplates"} |
| 318 | ] } } } |
| 319 | `), |
| 320 | }, |
| 321 | wantFeatures: RepositoryFeatures{ |
| 322 | PullRequestTemplateQuery: true, |
| 323 | }, |
| 324 | wantErr: false, |
| 325 | }, |
| 326 | { |
| 327 | name: "GHE has visibility field", |
| 328 | hostname: "git.my.org", |
| 329 | queryResponse: map[string]string{ |
nothing calls this directly
no test coverage detected