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

Function TestUpdateAlreadyUpToDate_JSON

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

Source from the content-addressed store, hash-verified

101}
102
103func TestUpdateAlreadyUpToDate_JSON(t *testing.T) {
104 f, stdout, _ := newTestFactory(t)
105
106 cmd := NewCmdUpdate(f)
107 cmd.SetArgs([]string{"--json"})
108
109 origFetch := fetchLatest
110 fetchLatest = func() (string, error) { return "1.0.0", nil }
111 defer func() { fetchLatest = origFetch }()
112
113 origVersion := currentVersion
114 currentVersion = func() string { return "1.0.0" }
115 defer func() { currentVersion = origVersion }()
116
117 err := cmd.Execute()
118 if err != nil {
119 t.Fatalf("unexpected error: %v", err)
120 }
121
122 out := stdout.String()
123 if !strings.Contains(out, `"action": "already_up_to_date"`) {
124 t.Errorf("expected already_up_to_date in JSON output, got: %s", out)
125 }
126 if !strings.Contains(out, `"ok": true`) {
127 t.Errorf("expected ok:true in JSON output, got: %s", out)
128 }
129}
130
131func TestUpdateAlreadyUpToDate_Human(t *testing.T) {
132 f, _, stderr := 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