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

Function TestClientFunc

pkg/cmd/issue/artifact/shared/shared_test.go:18–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

16)
17
18func TestClientFunc(t *testing.T) {
19 tests := []struct {
20 name string
21 httpClient func() (*http.Client, error)
22 wantErr string
23 }{
24 {
25 name: "creates a client",
26 httpClient: func() (*http.Client, error) { return &http.Client{}, nil },
27 },
28 {
29 name: "returns the HTTP client's error",
30 httpClient: func() (*http.Client, error) { return nil, errors.New("no token") },
31 wantErr: "no token",
32 },
33 }
34
35 for _, tt := range tests {
36 t.Run(tt.name, func(t *testing.T) {
37 f := &cmdutil.Factory{HttpClient: tt.httpClient}
38
39 c, err := ClientFunc(f)()
40
41 if tt.wantErr != "" {
42 require.EqualError(t, err, tt.wantErr)
43 assert.Nil(t, c)
44 return
45 }
46 require.NoError(t, err)
47 assert.NotNil(t, c)
48 })
49 }
50}
51
52func TestParseIssueArg(t *testing.T) {
53 tests := []struct {

Callers

nothing calls this directly

Calls 2

ClientFuncFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected