(t *testing.T)
| 319 | } |
| 320 | |
| 321 | func TestUpdateFetchError_Human(t *testing.T) { |
| 322 | f, _, _ := newTestFactory(t) |
| 323 | cmd := NewCmdUpdate(f) |
| 324 | cmd.SetArgs([]string{}) |
| 325 | |
| 326 | origFetch := fetchLatest |
| 327 | fetchLatest = func() (string, error) { return "", errors.New("network timeout") } |
| 328 | defer func() { fetchLatest = origFetch }() |
| 329 | |
| 330 | // Suppress cobra's default error printing. |
| 331 | cmd.SilenceErrors = true |
| 332 | cmd.SilenceUsage = true |
| 333 | |
| 334 | err := cmd.Execute() |
| 335 | if err == nil { |
| 336 | t.Fatal("expected non-nil error, got nil") |
| 337 | } |
| 338 | var netErr *errs.NetworkError |
| 339 | if !errors.As(err, &netErr) { |
| 340 | t.Fatalf("expected *errs.NetworkError, got %T: %v", err, err) |
| 341 | } |
| 342 | if netErr.Subtype != errs.SubtypeNetworkTransport { |
| 343 | t.Errorf("subtype = %q, want %q", netErr.Subtype, errs.SubtypeNetworkTransport) |
| 344 | } |
| 345 | if got := output.ExitCodeOf(err); got != output.ExitNetwork { |
| 346 | t.Errorf("expected ExitNetwork (%d), got %d", output.ExitNetwork, got) |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | // TestUpdateInvalidVersion_Human verifies a malformed registry version surfaces |
| 351 | // as a typed internal error in human mode, keeping the legacy exit code 5. |
nothing calls this directly
no test coverage detected