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

Function TestUpdateDevVersion_JSON

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

Source from the content-addressed store, hash-verified

436}
437
438func TestUpdateDevVersion_JSON(t *testing.T) {
439 // Same state-isolation rationale as TestUpdateNpm_JSON.
440 t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir())
441
442 f, stdout, _ := newTestFactory(t)
443 cmd := NewCmdUpdate(f)
444 cmd.SetArgs([]string{"--json"})
445
446 origFetch := fetchLatest
447 fetchLatest = func() (string, error) { return "1.0.0", nil }
448 defer func() { fetchLatest = origFetch }()
449 origVersion := currentVersion
450 currentVersion = func() string { return "DEV" }
451 defer func() { currentVersion = origVersion }()
452 mockDetectAndNpm(t,
453 selfupdate.DetectResult{Method: selfupdate.InstallNpm, ResolvedPath: "/node_modules/@larksuite/cli/bin/lark-cli", NpmAvailable: true},
454 func(version string) *selfupdate.NpmResult { return &selfupdate.NpmResult{} },
455 )
456
457 err := cmd.Execute()
458 if err != nil {
459 t.Fatalf("unexpected error: %v", err)
460 }
461 out := stdout.String()
462 if !strings.Contains(out, `"action": "updated"`) {
463 t.Errorf("expected updated in JSON output, got: %s", out)
464 }
465}
466
467func TestUpdateNpmFail_JSON(t *testing.T) {
468 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