MCPcopy Index your code
hub / github.com/cli/cli / TestRemoveCopilot

Function TestRemoveCopilot

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

Source from the content-addressed store, hash-verified

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…