MCPcopy Index your code
hub / github.com/cheat/cheat / TestPrompt

Function TestPrompt

internal/installer/prompt_test.go:11–136  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestPrompt(t *testing.T) {
12 // Save original stdin/stdout
13 oldStdin := os.Stdin
14 oldStdout := os.Stdout
15 defer func() {
16 os.Stdin = oldStdin
17 os.Stdout = oldStdout
18 }()
19
20 tests := []struct {
21 name string
22 prompt string
23 input string
24 defaultVal bool
25 want bool
26 wantErr bool
27 wantPrompt string
28 }{
29 {
30 name: "answer yes",
31 prompt: "Continue?",
32 input: "y\n",
33 defaultVal: false,
34 want: true,
35 wantPrompt: "Continue?: ",
36 },
37 {
38 name: "answer yes with uppercase",
39 prompt: "Continue?",
40 input: "Y\n",
41 defaultVal: false,
42 want: true,
43 wantPrompt: "Continue?: ",
44 },
45 {
46 name: "answer yes with spaces",
47 prompt: "Continue?",
48 input: " y \n",
49 defaultVal: false,
50 want: true,
51 wantPrompt: "Continue?: ",
52 },
53 {
54 name: "answer no",
55 prompt: "Continue?",
56 input: "n\n",
57 defaultVal: true,
58 want: false,
59 wantPrompt: "Continue?: ",
60 },
61 {
62 name: "answer no with any text",
63 prompt: "Continue?",
64 input: "anything\n",
65 defaultVal: true,
66 want: false,
67 wantPrompt: "Continue?: ",
68 },

Callers

nothing calls this directly

Calls 2

PromptFunction · 0.85
CopyMethod · 0.80

Tested by

no test coverage detected