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