(t *testing.T)
| 133 | } |
| 134 | |
| 135 | func TestActionsPickerOptions(t *testing.T) { |
| 136 | tests := []struct { |
| 137 | name string |
| 138 | actions []*management.Action |
| 139 | apiError error |
| 140 | assertOutput func(t testing.TB, options pickerOptions) |
| 141 | assertError func(t testing.TB, err error) |
| 142 | }{ |
| 143 | { |
| 144 | name: "happy path", |
| 145 | actions: []*management.Action{ |
| 146 | { |
| 147 | ID: auth0.String("some-id-1"), |
| 148 | Name: auth0.String("some-name-1"), |
| 149 | }, |
| 150 | { |
| 151 | ID: auth0.String("some-id-2"), |
| 152 | Name: auth0.String("some-name-2"), |
| 153 | }, |
| 154 | }, |
| 155 | assertOutput: func(t testing.TB, options pickerOptions) { |
| 156 | assert.Len(t, options, 2) |
| 157 | assert.Equal(t, "some-name-1 (some-id-1)", options[0].label) |
| 158 | assert.Equal(t, "some-id-1", options[0].value) |
| 159 | assert.Equal(t, "some-name-2 (some-id-2)", options[1].label) |
| 160 | assert.Equal(t, "some-id-2", options[1].value) |
| 161 | }, |
| 162 | assertError: func(t testing.TB, err error) { |
| 163 | t.Fail() |
| 164 | }, |
| 165 | }, |
| 166 | { |
| 167 | name: "no actions", |
| 168 | actions: []*management.Action{}, |
| 169 | assertOutput: func(t testing.TB, options pickerOptions) { |
| 170 | t.Fail() |
| 171 | }, |
| 172 | assertError: func(t testing.TB, err error) { |
| 173 | assert.ErrorContains(t, err, "there are currently no actions to choose from. Create one by running: `auth0 actions create`") |
| 174 | }, |
| 175 | }, |
| 176 | { |
| 177 | name: "API error", |
| 178 | apiError: errors.New("error"), |
| 179 | assertOutput: func(t testing.TB, options pickerOptions) { |
| 180 | t.Fail() |
| 181 | }, |
| 182 | assertError: func(t testing.TB, err error) { |
| 183 | assert.Error(t, err) |
| 184 | }, |
| 185 | }, |
| 186 | } |
| 187 | |
| 188 | for _, test := range tests { |
| 189 | t.Run(test.name, func(t *testing.T) { |
| 190 | ctrl := gomock.NewController(t) |
| 191 | defer ctrl.Finish() |
| 192 |
nothing calls this directly
no test coverage detected