MCPcopy Create free account
hub / github.com/appleboy/CodeGPT / TestIsCommandAvailable

Function TestIsCommandAvailable

util/util_test.go:9–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestIsCommandAvailable(t *testing.T) {
10 testCases := []struct {
11 name string
12 cmd string
13 want bool
14 setup func(t *testing.T)
15 }{
16 {
17 name: "command exists",
18 cmd: "ls",
19 want: true,
20 },
21 {
22 name: "command does not exist",
23 cmd: "nonexistentcommand",
24 want: false,
25 },
26 {
27 name: "command exists in path",
28 cmd: "git",
29 want: true,
30 setup: func(t *testing.T) {
31 t.Helper()
32 // Add /usr/local/bin to PATH for this test case
33 t.Setenv("PATH", "/usr/local/bin:"+os.Getenv("PATH"))
34 },
35 },
36 }
37
38 for _, tc := range testCases {
39 t.Run(tc.name, func(t *testing.T) {
40 if tc.setup != nil {
41 tc.setup(t)
42 }
43
44 got := IsCommandAvailable(tc.cmd)
45
46 if got != tc.want {
47 t.Errorf("IsCommandAvailable(%q) = %v; want %v", tc.cmd, got, tc.want)
48 }
49 })
50 }
51}
52
53func TestConvertToMap(t *testing.T) {
54 type args struct {

Callers

nothing calls this directly

Calls 1

IsCommandAvailableFunction · 0.85

Tested by

no test coverage detected