(t *testing.T)
| 16 | ) |
| 17 | |
| 18 | func 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 | |
| 52 | func TestParseIssueArg(t *testing.T) { |
| 53 | tests := []struct { |
nothing calls this directly
no test coverage detected