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

Function TestInvitationsPickerOptions

internal/cli/organizations_test.go:96–180  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

94}
95
96func TestInvitationsPickerOptions(t *testing.T) {
97 tests := []struct {
98 name string
99 invitations []*management.OrganizationInvitation
100 apiError error
101 assertOutput func(t testing.TB, options pickerOptions)
102 assertError func(t testing.TB, err error)
103 }{
104 {
105 name: "happy path",
106 invitations: []*management.OrganizationInvitation{
107 {
108 ID: auth0.String("inv-id-1"),
109 Invitee: &management.OrganizationInvitationInvitee{
110 Email: auth0.String("user1@example.com"),
111 },
112 },
113 {
114 ID: auth0.String("inv-id-2"),
115 Invitee: &management.OrganizationInvitationInvitee{
116 Email: auth0.String("user2@example.com"),
117 },
118 },
119 },
120 assertOutput: func(t testing.TB, options pickerOptions) {
121 assert.Len(t, options, 2)
122 assert.Equal(t, "user1@example.com (inv-id-1)", options[0].label)
123 assert.Equal(t, "inv-id-1", options[0].value)
124 assert.Equal(t, "user2@example.com (inv-id-2)", options[1].label)
125 assert.Equal(t, "inv-id-2", options[1].value)
126 },
127 assertError: func(t testing.TB, err error) {
128 t.Fail()
129 },
130 },
131 {
132 name: "no invitations",
133 invitations: []*management.OrganizationInvitation{},
134 assertOutput: func(t testing.TB, options pickerOptions) {
135 t.Fail()
136 },
137 assertError: func(t testing.TB, err error) {
138 assert.Error(t, err)
139 assert.ErrorContains(t, err, "there are currently no invitations to choose from")
140 },
141 },
142 {
143 name: "API error",
144 apiError: errors.New("api error"),
145 assertOutput: func(t testing.TB, options pickerOptions) {
146 t.Fail()
147 },
148 assertError: func(t testing.TB, err error) {
149 assert.Error(t, err)
150 assert.ErrorContains(t, err, "api error")
151 },
152 },
153 }

Callers

nothing calls this directly

Calls 5

EXPECTMethod · 0.95
NewMockOrganizationAPIFunction · 0.92
InvitationsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected