MCPcopy
hub / github.com/cli/cli / TestRequestableReviewersForCompletion

Function TestRequestableReviewersForCompletion

pkg/cmd/pr/shared/completion_test.go:12–120  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func 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(`

Callers

nothing calls this directly

Calls 8

RegisterMethod · 0.95
VerifyMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
NewFunction · 0.92
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected