MCPcopy Create free account
hub / github.com/cli/cli / TestStatusRun

Function TestStatusRun

pkg/cmd/status/status_test.go:87–482  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

85}
86
87func TestStatusRun(t *testing.T) {
88 tests := []struct {
89 name string
90 httpStubs func(*httpmock.Registry)
91 opts *StatusOptions
92 wantOut string
93 wantErrMsg string
94 }{
95 {
96 name: "nothing",
97 httpStubs: func(reg *httpmock.Registry) {
98 reg.Register(
99 httpmock.GraphQL("UserCurrent"),
100 httpmock.StringResponse(`{"data": {"viewer": {"login": "jillvalentine"}}}`))
101 reg.Register(
102 httpmock.GraphQL("AssignedSearch"),
103 httpmock.StringResponse(`{"data": { "assignments": {"nodes": [] }, "reviewRequested": {"nodes": []}}}`))
104 reg.Register(
105 httpmock.REST("GET", "notifications"),
106 httpmock.StringResponse(`[]`))
107 reg.Register(
108 httpmock.REST("GET", "users/jillvalentine/received_events"),
109 httpmock.StringResponse(`[]`))
110 },
111 opts: &StatusOptions{},
112 wantOut: "Assigned Issues │ Assigned Pull Requests \nNothing here ^_^ │ Nothing here ^_^ \n │ \nReview Requests │ Mentions \nNothing here ^_^ │ Nothing here ^_^ \n │ \nRepository Activity\nNothing here ^_^\n\n",
113 },
114 {
115 name: "notifications 404 is tolerated",
116 httpStubs: func(reg *httpmock.Registry) {
117 reg.Register(
118 httpmock.GraphQL("UserCurrent"),
119 httpmock.StringResponse(`{"data": {"viewer": {"login": "jillvalentine"}}}`))
120 reg.Register(
121 httpmock.GraphQL("AssignedSearch"),
122 httpmock.StringResponse(`{"data": { "assignments": {"nodes": [] }, "reviewRequested": {"nodes": []}}}`))
123 reg.Register(
124 httpmock.REST("GET", "notifications"),
125 httpmock.StatusStringResponse(http.StatusNotFound, `{"message":"Not Found"}`))
126 reg.Register(
127 httpmock.REST("GET", "users/jillvalentine/received_events"),
128 httpmock.StringResponse(`[]`))
129 },
130 opts: &StatusOptions{},
131 wantOut: "Assigned Issues │ Assigned Pull Requests \nNothing here ^_^ │ Nothing here ^_^ \n │ \nReview Requests │ Mentions \nNothing here ^_^ │ Nothing here ^_^ \n │ \nRepository Activity\nNothing here ^_^\n\n",
132 },
133 {
134 name: "something",
135 httpStubs: func(reg *httpmock.Registry) {
136 reg.Register(
137 httpmock.GraphQL("UserCurrent"),
138 httpmock.StringResponse(`{"data": {"viewer": {"login": "jillvalentine"}}}`))
139 reg.Register(
140 httpmock.REST("GET", "repos/rpd/todo/issues/110"),
141 httpmock.StringResponse(`{"body":"hello @jillvalentine how are you"}`))
142 reg.Register(
143 httpmock.REST("GET", "repos/rpd/todo/issues/4113"),
144 httpmock.StringResponse(`{"body":"this is a comment"}`))

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
RESTFunction · 0.92
StatusStringResponseFunction · 0.92
FileResponseFunction · 0.92
TestFunction · 0.92
testHostConfigTypeAlias · 0.85
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
statusRunFunction · 0.70

Tested by

no test coverage detected