-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfirm_internal_test.go
61 lines (50 loc) · 1.06 KB
/
confirm_internal_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package surveyexpect
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestConfirm_String(t *testing.T) {
t.Parallel()
expected := "Expect : Confirm Prompt\nMessage: \"ConfirmPrompt?\"\nAnswer : <no answer>\n"
c := &ConfirmPrompt{
message: "ConfirmPrompt?",
answer: noAnswer(),
}
assert.Equal(t, expected, c.String())
}
func TestConfirmAnswer_String(t *testing.T) {
t.Parallel()
testCases := []struct {
scenario string
interrupted bool
feedback string
expected string
}{
{
scenario: "interrupted",
interrupted: true,
expected: "\"answer\" and get interrupted",
},
{
scenario: "feedback",
feedback: "feedback",
expected: "\"answer\" and get feedback \"feedback\"",
},
{
scenario: "normal",
expected: `"answer"`,
},
}
for _, tc := range testCases {
tc := tc
t.Run(tc.scenario, func(t *testing.T) {
t.Parallel()
a := &ConfirmAnswer{
answer: "answer",
feedback: tc.feedback,
interrupted: tc.interrupted,
}
assert.Equal(t, tc.expected, a.String())
})
}
}