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

Function TestUserRolesToAddPickerOptions

internal/cli/users_roles_test.go:77–216  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

75}
76
77func TestUserRolesToAddPickerOptions(t *testing.T) {
78 tests := []struct {
79 name string
80 userID string
81 userRoles []*management.Role
82 allRoles []*management.Role
83 userAPIError error
84 roleAPIError error
85 assertOutput func(t testing.TB, options []string)
86 assertError func(t testing.TB, err error)
87 }{
88 {
89 name: "happy path",
90 userRoles: []*management.Role{
91 {
92 ID: auth0.String("some-id-1"),
93 Name: auth0.String("some-name-1"),
94 },
95 {
96 ID: auth0.String("some-id-2"),
97 Name: auth0.String("some-name-2"),
98 },
99 },
100 allRoles: []*management.Role{
101 {
102 ID: auth0.String("some-id-1"),
103 Name: auth0.String("some-name-1"),
104 },
105 {
106 ID: auth0.String("some-id-2"),
107 Name: auth0.String("some-name-2"),
108 },
109 {
110 ID: auth0.String("some-id-3"),
111 Name: auth0.String("some-name-3"),
112 },
113 {
114 ID: auth0.String("some-id-4"),
115 Name: auth0.String("some-name-4"),
116 },
117 },
118 assertOutput: func(t testing.TB, options []string) {
119 assert.Len(t, options, 2)
120 assert.Equal(t, "some-id-3 (Name: some-name-3)", options[0])
121 assert.Equal(t, "some-id-4 (Name: some-name-4)", options[1])
122 },
123 assertError: func(t testing.TB, err error) {
124 t.Fail()
125 },
126 },
127 {
128 name: "user API error",
129 userID: "some-id",
130 userAPIError: errors.New("error"),
131 assertOutput: func(t testing.TB, options []string) {
132 t.Fail()
133 },
134 assertError: func(t testing.TB, err error) {

Callers

nothing calls this directly

Calls 7

EXPECTMethod · 0.95
EXPECTMethod · 0.95
NewMockUserAPIFunction · 0.92
NewMockRoleAPIFunction · 0.92
RolesMethod · 0.65
ListMethod · 0.65

Tested by

no test coverage detected