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

Function TestRunAddItem_User

pkg/cmd/project/item-add/item_add_test.go:192–234  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

190}
191
192func TestRunAddItem_User(t *testing.T) {
193 tests := []struct {
194 name string
195 stdoutTTY bool
196 want string
197 }{
198 {
199 name: "tty",
200 stdoutTTY: true,
201 want: "Added item\n",
202 },
203 {
204 name: "non-tty",
205 want: "project item ID\n",
206 },
207 }
208
209 for _, tt := range tests {
210 t.Run(tt.name, func(t *testing.T) {
211 defer gock.Off()
212 gock.Observe(gock.DumpRequest)
213 setupRunAddItemUserMocks()
214
215 client := queries.NewTestClient()
216
217 ios, _, stdout, _ := iostreams.Test()
218 ios.SetStdoutTTY(tt.stdoutTTY)
219 config := addItemConfig{
220 opts: addItemOpts{
221 owner: "monalisa",
222 number: 1,
223 itemURL: "https://github.com/cli/go-gh/issues/1",
224 },
225 client: client,
226 io: ios,
227 }
228
229 err := runAddItem(config)
230 require.NoError(t, err)
231 assert.Equal(t, tt.want, stdout.String())
232 })
233 }
234}
235
236func TestRunAddItem_Org(t *testing.T) {
237 defer gock.Off()

Callers

nothing calls this directly

Calls 8

NewTestClientFunction · 0.92
TestFunction · 0.92
setupRunAddItemUserMocksFunction · 0.85
runAddItemFunction · 0.85
SetStdoutTTYMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected