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

Function TestUpdateForce_JSON

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

Source from the content-addressed store, hash-verified

269}
270
271func TestUpdateForce_JSON(t *testing.T) {
272 // Same state-isolation rationale as TestUpdateNpm_JSON.
273 t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir())
274
275 f, stdout, _ := newTestFactory(t)
276 cmd := NewCmdUpdate(f)
277 cmd.SetArgs([]string{"--force", "--json"})
278
279 origFetch := fetchLatest
280 fetchLatest = func() (string, error) { return "1.0.0", nil }
281 defer func() { fetchLatest = origFetch }()
282 origVersion := currentVersion
283 currentVersion = func() string { return "1.0.0" }
284 defer func() { currentVersion = origVersion }()
285 mockDetectAndNpm(t,
286 selfupdate.DetectResult{Method: selfupdate.InstallNpm, ResolvedPath: "/node_modules/@larksuite/cli/bin/lark-cli", NpmAvailable: true},
287 func(version string) *selfupdate.NpmResult { return &selfupdate.NpmResult{} },
288 )
289
290 err := cmd.Execute()
291 if err != nil {
292 t.Fatalf("unexpected error: %v", err)
293 }
294 out := stdout.String()
295 if !strings.Contains(out, `"action": "updated"`) {
296 t.Errorf("expected updated in JSON output, got: %s", out)
297 }
298}
299
300func TestUpdateFetchError_JSON(t *testing.T) {
301 f, stdout, _ := newTestFactory(t)

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected