(t *testing.T)
| 142 | } |
| 143 | |
| 144 | func 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. |
| 170 | func createTarGzBuffer(t *testing.T, files map[string][]byte) []byte { |
nothing calls this directly
no test coverage detected
searching dependent graphs…