MCPcopy Create free account
hub / github.com/larksuite/cli / TestUpdateFetchError_JSON

Function TestUpdateFetchError_JSON

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

Source from the content-addressed store, hash-verified

298}
299
300func 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
321func TestUpdateFetchError_Human(t *testing.T) {
322 f, _, _ := newTestFactory(t)

Callers

nothing calls this directly

Calls 4

NewCmdUpdateFunction · 0.85
newTestFactoryFunction · 0.70
StringMethod · 0.45
ContainsMethod · 0.45

Tested by

no test coverage detected