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

Function TestUndeployedActionsPickerOptions

internal/cli/actions_test.go:214–291  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

212}
213
214func TestUndeployedActionsPickerOptions(t *testing.T) {
215 tests := []struct {
216 name string
217 actions []*management.Action
218 apiError error
219 assertOutput func(t testing.TB, options pickerOptions)
220 assertError func(t testing.TB, err error)
221 }{
222 {
223 name: "happy path",
224 actions: []*management.Action{
225 {
226 ID: auth0.String("some-id-1"),
227 Name: auth0.String("some-name-1"),
228 },
229 {
230 ID: auth0.String("some-id-2"),
231 Name: auth0.String("some-name-2"),
232 },
233 },
234 assertOutput: func(t testing.TB, options pickerOptions) {
235 assert.Len(t, options, 2)
236 assert.Equal(t, "some-name-1 (some-id-1)", options[0].label)
237 assert.Equal(t, "some-id-1", options[0].value)
238 assert.Equal(t, "some-name-2 (some-id-2)", options[1].label)
239 assert.Equal(t, "some-id-2", options[1].value)
240 },
241 assertError: func(t testing.TB, err error) {
242 t.Fail()
243 },
244 },
245 {
246 name: "no actions",
247 actions: []*management.Action{},
248 assertOutput: func(t testing.TB, options pickerOptions) {
249 t.Fail()
250 },
251 assertError: func(t testing.TB, err error) {
252 assert.ErrorContains(t, err, "there are currently no actions to deploy")
253 },
254 },
255 {
256 name: "API error",
257 apiError: errors.New("error"),
258 assertOutput: func(t testing.TB, options pickerOptions) {
259 t.Fail()
260 },
261 assertError: func(t testing.TB, err error) {
262 assert.Error(t, err)
263 },
264 },
265 }
266
267 for _, test := range tests {
268 t.Run(test.name, func(t *testing.T) {
269 ctrl := gomock.NewController(t)
270 defer ctrl.Finish()
271

Callers

nothing calls this directly

Calls 5

EXPECTMethod · 0.95
NewMockActionAPIFunction · 0.92
ListMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected