| 146 | } |
| 147 | |
| 148 | func TestRunPromptError(t *testing.T) { |
| 149 | // Save original stdin |
| 150 | oldStdin := os.Stdin |
| 151 | defer func() { |
| 152 | os.Stdin = oldStdin |
| 153 | }() |
| 154 | |
| 155 | // Close stdin to cause prompt error |
| 156 | r, w, _ := os.Pipe() |
| 157 | os.Stdin = r |
| 158 | r.Close() |
| 159 | w.Close() |
| 160 | |
| 161 | tempDir, _ := os.MkdirTemp("", "cheat-installer-prompt-test-*") |
| 162 | defer os.RemoveAll(tempDir) |
| 163 | |
| 164 | err := Run("test", filepath.Join(tempDir, "conf.yml")) |
| 165 | if err == nil { |
| 166 | t.Error("expected error when prompt fails, got nil") |
| 167 | } |
| 168 | if !strings.Contains(err.Error(), "failed to prompt") { |
| 169 | t.Errorf("expected 'failed to prompt' error, got: %v", err) |
| 170 | } |
| 171 | } |
| 172 | |
| 173 | func TestRunStringReplacements(t *testing.T) { |
| 174 | // Test that path replacements work correctly |