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

Function TestRulesPickerOptions

internal/cli/rules_test.go:17–94  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15)
16
17func TestRulesPickerOptions(t *testing.T) {
18 tests := []struct {
19 name string
20 rules []*management.Rule
21 apiError error
22 assertOutput func(t testing.TB, options pickerOptions)
23 assertError func(t testing.TB, err error)
24 }{
25 {
26 name: "happy path",
27 rules: []*management.Rule{
28 {
29 ID: auth0.String("some-id-1"),
30 Name: auth0.String("some-name-1"),
31 },
32 {
33 ID: auth0.String("some-id-2"),
34 Name: auth0.String("some-name-2"),
35 },
36 },
37 assertOutput: func(t testing.TB, options pickerOptions) {
38 assert.Len(t, options, 2)
39 assert.Equal(t, "some-name-1", options[0].label)
40 assert.Equal(t, "some-id-1", options[0].value)
41 assert.Equal(t, "some-name-2", options[1].label)
42 assert.Equal(t, "some-id-2", options[1].value)
43 },
44 assertError: func(t testing.TB, err error) {
45 t.Fail()
46 },
47 },
48 {
49 name: "no rules",
50 rules: []*management.Rule{},
51 assertOutput: func(t testing.TB, options pickerOptions) {
52 t.Fail()
53 },
54 assertError: func(t testing.TB, err error) {
55 assert.ErrorContains(t, err, "there are currently no rules to choose from")
56 },
57 },
58 {
59 name: "API error",
60 apiError: errors.New("error"),
61 assertOutput: func(t testing.TB, options pickerOptions) {
62 t.Fail()
63 },
64 assertError: func(t testing.TB, err error) {
65 assert.Error(t, err)
66 },
67 },
68 }
69
70 for _, test := range tests {
71 t.Run(test.name, func(t *testing.T) {
72 ctrl := gomock.NewController(t)
73 defer ctrl.Finish()
74

Callers

nothing calls this directly

Calls 5

EXPECTMethod · 0.95
rulePickerOptionsMethod · 0.95
NewMockRuleAPIFunction · 0.92
ListMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected