MCPcopy Create free account
hub / github.com/auth0/auth0-cli / TestPickerOptions

Function TestPickerOptions

internal/cli/picker_options_test.go:9–65  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestPickerOptions(t *testing.T) {
10 t.Run("returns the labels", func(t *testing.T) {
11 options := pickerOptions{pickerOption{label: "Foo"}, pickerOption{label: "Bar"}}
12 want := []string{"Foo", "Bar"}
13 got := options.labels()
14
15 assert.Equal(t, want, got)
16 })
17
18 t.Run("returns the default label", func(t *testing.T) {
19 options := pickerOptions{pickerOption{label: "Foo"}, pickerOption{label: "Bar"}}
20 want := "Foo"
21 got := options.defaultLabel()
22
23 assert.Equal(t, want, got)
24 })
25
26 t.Run("returns an empty label when there are no options", func(t *testing.T) {
27 options := pickerOptions{}
28 want := ""
29 got := options.defaultLabel()
30
31 assert.Equal(t, want, got)
32 })
33
34 t.Run("returns the value for a given label", func(t *testing.T) {
35 options := pickerOptions{pickerOption{label: "Foo", value: "0"}, pickerOption{label: "Bar", value: "1"}}
36 want := "1"
37 got := options.getValue("Bar")
38
39 assert.Equal(t, want, got)
40 })
41
42 t.Run("returns an empty value given a non-existent label", func(t *testing.T) {
43 options := pickerOptions{pickerOption{label: "Foo"}}
44 want := ""
45 got := options.getValue("Bar")
46
47 assert.Equal(t, want, got)
48 })
49
50 t.Run("return the values for a given set of labels", func(t *testing.T) {
51 options := pickerOptions{pickerOption{label: "Foo", value: "0"}, pickerOption{label: "Bar", value: "1"}, pickerOption{label: "Baz", value: "2"}}
52 want := []string{"0", "2"}
53 got := options.getValues("Foo", "Baz")
54
55 assert.Equal(t, want, got)
56 })
57
58 t.Run("returns empty values for a given set of non-existant labels", func(t *testing.T) {
59 options := pickerOptions{pickerOption{label: "Foo", value: "0"}, pickerOption{label: "Bar", value: "1"}, pickerOption{label: "Baz", value: "2"}}
60 want := []string(nil)
61 got := options.getValues("Buz")
62
63 assert.Equal(t, want, got)
64 })
65}

Callers

nothing calls this directly

Calls 4

labelsMethod · 0.95
defaultLabelMethod · 0.95
getValueMethod · 0.95
getValuesMethod · 0.95

Tested by

no test coverage detected