(t *testing.T)
| 154 | } |
| 155 | |
| 156 | func 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 | |
| 187 | func TestUpdateManual_Human(t *testing.T) { |
| 188 | f, _, stderr := newTestFactory(t) |
nothing calls this directly
no test coverage detected