MCPcopy Create free account
hub / github.com/OctopusDeploy/cli / TestSelectForMultipleItem

Function TestSelectForMultipleItem

pkg/question/selectors/selector_test.go:30–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28}
29
30func TestSelectForMultipleItem(t *testing.T) {
31 items := []*Item{
32 {
33 id: "1",
34 name: "name",
35 },
36 {
37 id: "2",
38 name: "name 2",
39 },
40 }
41 itemsCallback := func() ([]*Item, error) {
42 return items, nil
43 }
44 pa := []*testutil.PA{
45 {
46 Prompt: &survey.Select{
47 Message: "question",
48 Options: []string{items[0].name, items[1].name},
49 },
50 Answer: "name 2",
51 },
52 }
53 mockAsker, checkRemainingPrompts := testutil.NewMockAsker(t, pa)
54 selectedItem, err := Select(mockAsker, "question", itemsCallback, func(item *Item) string { return item.name })
55 checkRemainingPrompts()
56 assert.Nil(t, err)
57 assert.Equal(t, selectedItem.id, "2")
58}

Callers

nothing calls this directly

Calls 2

NewMockAskerFunction · 0.92
SelectFunction · 0.70

Tested by

no test coverage detected