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

Function TestListRunDefaultHost

pkg/cmd/event/subscription/list/list_test.go:225–249  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

223}
224
225func TestListRunDefaultHost(t *testing.T) {
226 ios, _, stdout, stderr := iostreams.Test()
227 cfg := config.NewMockConfig()
228 authCfg := cfg.Authentication()
229 authCfg.SetDefaultHost("example.com", "GH_HOST")
230 cfg.AuthenticationFunc = func() gh.AuthConfig { return authCfg }
231 clientErr := errors.New("event subscriptions are only supported on github.com")
232 var gotHost string
233 opts := &ListOptions{
234 IO: ios,
235 Config: func() (gh.Config, error) { return cfg, nil },
236 EventClient: func(host string) (client.EventClient, error) {
237 gotHost = host
238 return nil, clientErr
239 },
240 Limit: 30,
241 }
242
243 err := listRun(context.Background(), opts)
244
245 require.ErrorIs(t, err, clientErr)
246 assert.Equal(t, "example.com", gotHost)
247 assert.Empty(t, stdout.String())
248 assert.Empty(t, stderr.String())
249}

Callers

nothing calls this directly

Calls 8

TestFunction · 0.92
NewMockConfigFunction · 0.92
EqualMethod · 0.80
EmptyMethod · 0.80
listRunFunction · 0.70
AuthenticationMethod · 0.65
SetDefaultHostMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected