(t *testing.T)
| 298 | } |
| 299 | |
| 300 | func TestUpdateFetchError_JSON(t *testing.T) { |
| 301 | f, stdout, _ := newTestFactory(t) |
| 302 | cmd := NewCmdUpdate(f) |
| 303 | cmd.SetArgs([]string{"--json"}) |
| 304 | |
| 305 | origFetch := fetchLatest |
| 306 | fetchLatest = func() (string, error) { return "", errors.New("network timeout") } |
| 307 | defer func() { fetchLatest = origFetch }() |
| 308 | |
| 309 | err := cmd.Execute() |
| 310 | // cobra silences errors when RunE returns; we just check stdout |
| 311 | _ = err |
| 312 | out := stdout.String() |
| 313 | if !strings.Contains(out, `"ok": false`) { |
| 314 | t.Errorf("expected ok:false in JSON output, got: %s", out) |
| 315 | } |
| 316 | if !strings.Contains(out, "network timeout") { |
| 317 | t.Errorf("expected 'network timeout' in JSON output, got: %s", out) |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | func TestUpdateFetchError_Human(t *testing.T) { |
| 322 | f, _, _ := newTestFactory(t) |
nothing calls this directly
no test coverage detected