forked from AlecAivazis/survey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
select.go
73 lines (68 loc) · 1.42 KB
/
select.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
62
63
64
65
66
67
68
69
70
71
72
73
package main
import (
"github.com/AlecAivazis/survey/v2"
"github.com/AlecAivazis/survey/v2/tests/util"
)
var answer = ""
var goodTable = []TestUtil.TestTableEntry{
{
"standard", &survey.Select{
Message: "Choose a color:",
Options: []string{"red", "blue", "green"},
}, &answer, nil,
},
{
"short", &survey.Select{
Message: "Choose a color:",
Options: []string{"red", "blue"},
}, &answer, nil,
},
{
"default", &survey.Select{
Message: "Choose a color (should default blue):",
Options: []string{"red", "blue", "green"},
Default: "blue",
}, &answer, nil,
},
{
"one", &survey.Select{
Message: "Choose one:",
Options: []string{"hello"},
}, &answer, nil,
},
{
"no help, type ?", &survey.Select{
Message: "Choose a color:",
Options: []string{"red", "blue"},
}, &answer, nil,
},
{
"passes through bottom", &survey.Select{
Message: "Choose one:",
Options: []string{"red", "blue"},
}, &answer, nil,
},
{
"passes through top", &survey.Select{
Message: "Choose one:",
Options: []string{"red", "blue"},
}, &answer, nil,
},
{
"can navigate with j/k", &survey.Select{
Message: "Choose one:",
Options: []string{"red", "blue", "green"},
}, &answer, nil,
},
}
var badTable = []TestUtil.TestTableEntry{
{
"no options", &survey.Select{
Message: "Choose one:",
}, &answer, nil,
},
}
func main() {
TestUtil.RunTable(goodTable)
TestUtil.RunErrorTable(badTable)
}