(t *testing.T)
| 12 | ) |
| 13 | |
| 14 | func TestIssueFeatures(t *testing.T) { |
| 15 | issueFieldsWithRelationships := `{"data":{"Issue":{"fields":[{"name":"title"},{"name":"body"},{"name":"blockedBy"}]}}}` |
| 16 | issueFieldsWithoutRelationships := `{"data":{"Issue":{"fields":[{"name":"title"},{"name":"body"}]}}}` |
| 17 | |
| 18 | tests := []struct { |
| 19 | name string |
| 20 | hostname string |
| 21 | queryResponse map[string]string |
| 22 | wantFeatures IssueFeatures |
| 23 | wantErr bool |
| 24 | }{ |
| 25 | { |
| 26 | name: "github.com", |
| 27 | hostname: "github.com", |
| 28 | wantFeatures: IssueFeatures{ |
| 29 | ApiActorsSupported: true, |
| 30 | IssueRelationshipsSupported: true, |
| 31 | }, |
| 32 | wantErr: false, |
| 33 | }, |
| 34 | { |
| 35 | name: "ghec data residency (ghe.com)", |
| 36 | hostname: "stampname.ghe.com", |
| 37 | wantFeatures: IssueFeatures{ |
| 38 | ApiActorsSupported: true, |
| 39 | IssueRelationshipsSupported: true, |
| 40 | }, |
| 41 | wantErr: false, |
| 42 | }, |
| 43 | { |
| 44 | name: "GHE with relationship support", |
| 45 | hostname: "git.my.org", |
| 46 | queryResponse: map[string]string{ |
| 47 | `query Issue_fields`: issueFieldsWithRelationships, |
| 48 | }, |
| 49 | wantFeatures: IssueFeatures{ |
| 50 | ApiActorsSupported: false, |
| 51 | IssueRelationshipsSupported: true, |
| 52 | }, |
| 53 | wantErr: false, |
| 54 | }, |
| 55 | { |
| 56 | name: "GHE without relationship support", |
| 57 | hostname: "git.my.org", |
| 58 | queryResponse: map[string]string{ |
| 59 | `query Issue_fields`: issueFieldsWithoutRelationships, |
| 60 | }, |
| 61 | wantFeatures: IssueFeatures{ |
| 62 | ApiActorsSupported: false, |
| 63 | IssueRelationshipsSupported: false, |
| 64 | }, |
| 65 | wantErr: false, |
| 66 | }, |
| 67 | } |
| 68 | |
| 69 | for _, tt := range tests { |
| 70 | t.Run(tt.name, func(t *testing.T) { |
| 71 | reg := &httpmock.Registry{} |
nothing calls this directly
no test coverage detected