MCPcopy Index your code
hub / github.com/larksuite/cli / TestUpdateFetchError_Human

Function TestUpdateFetchError_Human

cmd/update/update_test.go:321–348  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

319}
320
321func 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.

Callers

nothing calls this directly

Calls 4

ExitCodeOfFunction · 0.92
NewCmdUpdateFunction · 0.85
AsMethod · 0.80
newTestFactoryFunction · 0.70

Tested by

no test coverage detected