(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func TestRequestableReviewersForCompletion(t *testing.T) { |
| 13 | tests := []struct { |
| 14 | name string |
| 15 | expectedReviewers []string |
| 16 | httpStubs func(*httpmock.Registry, *testing.T) |
| 17 | }{ |
| 18 | { |
| 19 | name: "when users and teams are both available, both are listed", |
| 20 | expectedReviewers: []string{"MonaLisa\tMona Display Name", "OWNER/core", "OWNER/robots", "hubot"}, |
| 21 | httpStubs: func(reg *httpmock.Registry, t *testing.T) { |
| 22 | reg.Register( |
| 23 | httpmock.GraphQL(`query UserCurrent\b`), |
| 24 | httpmock.StringResponse(`{"data": {"viewer": {"login": "OWNER"} } }`)) |
| 25 | reg.Register( |
| 26 | httpmock.GraphQL(`query RepositoryAssignableUsers\b`), |
| 27 | httpmock.StringResponse(` |
| 28 | { "data": { "repository": { "assignableUsers": { |
| 29 | "nodes": [ |
| 30 | { "login": "hubot", "id": "HUBOTID", "name": "" }, |
| 31 | { "login": "MonaLisa", "id": "MONAID", "name": "Mona Display Name" } |
| 32 | ], |
| 33 | "pageInfo": { "hasNextPage": false } |
| 34 | } } } } |
| 35 | `)) |
| 36 | reg.Register( |
| 37 | httpmock.GraphQL(`query OrganizationTeamList\b`), |
| 38 | httpmock.StringResponse(` |
| 39 | { "data": { "organization": { "teams": { |
| 40 | "nodes": [ |
| 41 | { "slug": "core", "id": "COREID" }, |
| 42 | { "slug": "robots", "id": "ROBOTID" } |
| 43 | ], |
| 44 | "pageInfo": { "hasNextPage": false } |
| 45 | } } } } |
| 46 | `)) |
| 47 | }, |
| 48 | }, |
| 49 | { |
| 50 | name: "when users are available but teams aren't, users are listed", |
| 51 | expectedReviewers: []string{"MonaLisa\tMona Display Name", "hubot"}, |
| 52 | httpStubs: func(reg *httpmock.Registry, t *testing.T) { |
| 53 | reg.Register( |
| 54 | httpmock.GraphQL(`query UserCurrent\b`), |
| 55 | httpmock.StringResponse(`{"data": {"viewer": {"login": "OWNER"} } }`)) |
| 56 | reg.Register( |
| 57 | httpmock.GraphQL(`query RepositoryAssignableUsers\b`), |
| 58 | httpmock.StringResponse(` |
| 59 | { "data": { "repository": { "assignableUsers": { |
| 60 | "nodes": [ |
| 61 | { "login": "hubot", "id": "HUBOTID", "name": "" }, |
| 62 | { "login": "MonaLisa", "id": "MONAID", "name": "Mona Display Name" } |
| 63 | ], |
| 64 | "pageInfo": { "hasNextPage": false } |
| 65 | } } } } |
| 66 | `)) |
| 67 | reg.Register( |
| 68 | httpmock.GraphQL(`query OrganizationTeamList\b`), |
| 69 | httpmock.StringResponse(` |
nothing calls this directly
no test coverage detected