MCPcopy Index your code
hub / github.com/coder/coder / TestMultiSelect

Function TestMultiSelect

cli/cliui/select_test.go:157–196  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

155}
156
157func TestMultiSelect(t *testing.T) {
158 t.Parallel()
159
160 tests := []struct {
161 name string
162 items []string
163 allowCustom bool
164 want []string
165 }{
166 {
167 name: "MultiSelect",
168 items: []string{"aaa", "bbb", "ccc"},
169 allowCustom: false,
170 want: []string{"aaa", "bbb", "ccc"},
171 },
172 {
173 name: "MultiSelectWithCustomInput",
174 items: []string{"Code", "Chairs", "Whale", "Diamond", "Carrot"},
175 allowCustom: true,
176 want: []string{"Code", "Chairs", "Whale", "Diamond", "Carrot"},
177 },
178 }
179
180 for _, tt := range tests {
181 t.Run(tt.name, func(t *testing.T) {
182 t.Parallel()
183
184 ptty := ptytest.New(t)
185 msgChan := make(chan []string)
186
187 go func() {
188 resp, err := newMultiSelect(ptty, tt.items, tt.allowCustom)
189 assert.NoError(t, err)
190 msgChan <- resp
191 }()
192
193 require.Equal(t, tt.want, <-msgChan)
194 })
195 }
196}
197
198func newMultiSelect(pty *ptytest.PTY, items []string, custom bool) ([]string, error) {
199 var values []string

Callers

nothing calls this directly

Calls 4

NewFunction · 0.92
newMultiSelectFunction · 0.85
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected