(t *testing.T)
| 162 | } |
| 163 | |
| 164 | func TestIntegrateCmd_RunE_Remove_E2E(t *testing.T) { |
| 165 | if runtime.GOOS != "windows" { |
| 166 | if _, err := os.Stat("/bin/bash"); err != nil { |
| 167 | t.Skip("no usable bash on this host") |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | // Register first (sets up the same temp home dir that --remove will tear down). |
| 172 | homeDir := t.TempDir() |
| 173 | if runtime.GOOS == "windows" { |
| 174 | t.Setenv("USERPROFILE", homeDir) |
| 175 | } else { |
| 176 | t.Setenv("HOME", homeDir) |
| 177 | t.Setenv("SHELL", "/bin/bash") |
| 178 | if err := os.WriteFile(filepath.Join(homeDir, ".bashrc"), nil, 0o644); err != nil { |
| 179 | t.Fatal(err) |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | register := &integrateCmd{} |
| 184 | if _, err := runCommand(t, register.Command(configs.NewCeler())); err != nil { |
| 185 | t.Fatalf("register should succeed: %v", err) |
| 186 | } |
| 187 | |
| 188 | remove := &integrateCmd{} |
| 189 | if _, err := runCommand(t, remove.Command(configs.NewCeler()), "--remove"); err != nil { |
| 190 | t.Fatalf("--remove should succeed: %v", err) |
| 191 | } |
| 192 | |
| 193 | // After --remove, the binary and completion file should be gone. |
| 194 | for _, path := range integrateArtifacts(homeDir) { |
| 195 | if fileio.PathExists(path) { |
| 196 | t.Errorf("integrate --remove should delete %s", path) |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | func TestIntegrateCmd_DetectShell_PanicSafe(t *testing.T) { |
| 202 | // Cleanup. |
nothing calls this directly
no test coverage detected