(t *testing.T)
| 49 | } |
| 50 | |
| 51 | func TestRunAliasListCommand_JSONFormatEmpty(t *testing.T) { |
| 52 | // Not parallel: SetConfigDir mutates process-global state. |
| 53 | dir := t.TempDir() |
| 54 | paths.SetConfigDir(dir) |
| 55 | t.Cleanup(func() { paths.SetConfigDir("") }) |
| 56 | |
| 57 | var buf bytes.Buffer |
| 58 | cmd := &cobra.Command{} |
| 59 | cmd.SetOut(&buf) |
| 60 | require.NoError(t, runAliasListCommand(cmd, nil, true)) |
| 61 | |
| 62 | // With no aliases the JSON output is an empty array, never "null". |
| 63 | var entries []aliasListEntry |
| 64 | require.NoError(t, json.Unmarshal(buf.Bytes(), &entries)) |
| 65 | assert.Empty(t, entries) |
| 66 | assert.Equal(t, "[]", string(bytes.TrimSpace(buf.Bytes()))) |
| 67 | } |
nothing calls this directly
no test coverage detected