MCPcopy Create free account
hub / github.com/cli/cli / TestRemoveCopilot

Function TestRemoveCopilot

pkg/cmd/copilot/copilot_test.go:148–171  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func TestRemoveCopilot(t *testing.T) {
149 t.Run("removes existing install directory", func(t *testing.T) {
150 // Create a temporary directory to simulate the install directory
151 tmpDir := t.TempDir()
152 installDir := filepath.Join(tmpDir, "copilot")
153 require.NoError(t, os.MkdirAll(installDir, 0755), "failed to create test directory")
154 // Create a dummy file in the directory
155 dummyFile := filepath.Join(installDir, "copilot")
156 require.NoError(t, os.WriteFile(dummyFile, []byte("test"), 0755), "failed to create test file")
157
158 err := removeCopilot(installDir)
159 require.NoError(t, err, "unexpected error")
160
161 _, err = os.Stat(installDir)
162 require.True(t, os.IsNotExist(err), "expected install directory to be removed")
163 })
164
165 t.Run("handles non-existent directory", func(t *testing.T) {
166 tmpDir := t.TempDir()
167 installDir := filepath.Join(tmpDir, "copilot")
168
169 require.ErrorContains(t, removeCopilot(installDir), "failed to remove Copilot CLI")
170 })
171}
172
173// createTarGzBuffer creates a tar.gz archive in memory with the given files.
174func createTarGzBuffer(t *testing.T, files map[string][]byte) []byte {

Callers

nothing calls this directly

Calls 3

removeCopilotFunction · 0.85
JoinMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected