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

Function TestRemoveCopilot

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

Source from the content-addressed store, hash-verified

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