MCPcopy Create free account
hub / github.com/diillson/chatcli / TestGetShellHistory

Function TestGetShellHistory

utils/shell_utils_test.go:52–102  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestGetShellHistory(t *testing.T) {
53 testCases := []struct {
54 name string
55 shell string
56 historyContent string
57 expectedContent string
58 expectError bool
59 }{
60 {
61 name: "Bash History",
62 shell: "bash",
63 historyContent: "ls -la\ngit status",
64 expectedContent: "ls -la\ngit status",
65 expectError: false,
66 },
67 {
68 name: "Zsh History",
69 shell: "zsh",
70 historyContent: ": 1663200000:0;ls -la\n: 1663200001:0;git status",
71 expectedContent: "ls -la\ngit status",
72 expectError: false,
73 },
74 {
75 name: "Fish History",
76 shell: "fish",
77 historyContent: "- cmd: ls -la\n- cmd: git status",
78 expectedContent: "- cmd: ls -la\n- cmd: git status", // fish não tem processamento especial
79 expectError: false,
80 },
81 {
82 name: "Unsupported Shell",
83 shell: "csh",
84 expectError: true,
85 },
86 }
87
88 for _, tc := range testCases {
89 t.Run(tc.name, func(t *testing.T) {
90 setupShellTest(t, tc.shell, tc.historyContent)
91
92 content, err := GetShellHistory()
93
94 if tc.expectError {
95 assert.Error(t, err)
96 } else {
97 require.NoError(t, err)
98 assert.Equal(t, tc.expectedContent, content)
99 }
100 })
101 }
102}
103
104func TestGetShellHistory_FileNotExist(t *testing.T) {
105 setupShellTest(t, "bash", "")

Callers

nothing calls this directly

Calls 5

setupShellTestFunction · 0.85
GetShellHistoryFunction · 0.85
EqualMethod · 0.80
RunMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected