MCPcopy
hub / github.com/cheat/cheat / TestRunPromptError

Function TestRunPromptError

internal/installer/run_test.go:148–171  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

146}
147
148func 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
173func TestRunStringReplacements(t *testing.T) {
174 // Test that path replacements work correctly

Callers

nothing calls this directly

Calls 1

RunFunction · 0.85

Tested by

no test coverage detected