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

Function TestUpdateManual_JSON

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

Source from the content-addressed store, hash-verified

154}
155
156func TestUpdateManual_JSON(t *testing.T) {
157 f, stdout, _ := newTestFactory(t)
158 cmd := NewCmdUpdate(f)
159 cmd.SetArgs([]string{"--json"})
160 cmd.SilenceErrors = true
161 cmd.SilenceUsage = true
162
163 origFetch := fetchLatest
164 fetchLatest = func() (string, error) { return "2.0.0", nil }
165 defer func() { fetchLatest = origFetch }()
166 origVersion := currentVersion
167 currentVersion = func() string { return "1.0.0" }
168 defer func() { currentVersion = origVersion }()
169 mockDetect(t, selfupdate.DetectResult{Method: selfupdate.InstallManual, ResolvedPath: "/usr/local/bin/lark-cli"})
170
171 err := cmd.Execute()
172 if err != nil {
173 t.Fatalf("unexpected error: %v", err)
174 }
175 out := stdout.String()
176 if !strings.Contains(out, `"action": "manual_required"`) {
177 t.Errorf("expected manual_required in output, got: %s", out)
178 }
179 if !strings.Contains(out, "not installed via npm") {
180 t.Errorf("expected accurate reason in output, got: %s", out)
181 }
182 if !strings.Contains(out, "releases/tag/v2.0.0") {
183 t.Errorf("expected version-pinned URL in output, got: %s", out)
184 }
185}
186
187func TestUpdateManual_Human(t *testing.T) {
188 f, _, stderr := newTestFactory(t)

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected