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

Function TestCustomDomainsPickerOptions

internal/cli/custom_domains_test.go:88–201  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

86}
87
88func TestCustomDomainsPickerOptions(t *testing.T) {
89 tests := []struct {
90 name string
91 customDomains []*management.CustomDomain
92 apiError error
93 assertOutput func(t testing.TB, options pickerOptions)
94 assertError func(t testing.TB, err error)
95 }{
96 {
97 name: "happy path",
98 customDomains: []*management.CustomDomain{
99 {
100 ID: auth0.String("some-id-1"),
101 Domain: auth0.String("some-domain-1"),
102 Status: auth0.String("ready"),
103 },
104 {
105 ID: auth0.String("some-id-2"),
106 Domain: auth0.String("some-domain-2"),
107 Status: auth0.String("ready"),
108 },
109 },
110 assertOutput: func(t testing.TB, options pickerOptions) {
111 assert.Len(t, options, 2)
112 assert.Equal(t, "some-domain-1 (some-id-1)", options[0].label)
113 assert.Equal(t, "some-id-1", options[0].value)
114 assert.Equal(t, "some-domain-2 (some-id-2)", options[1].label)
115 assert.Equal(t, "some-id-2", options[1].value)
116 },
117 assertError: func(t testing.TB, err error) {
118 t.Fail()
119 },
120 },
121 {
122 name: "custom domains with a non-ready status",
123 customDomains: []*management.CustomDomain{
124 {
125 ID: auth0.String("some-id-1"),
126 Domain: auth0.String("some-domain-1"),
127 Status: auth0.String("pending_verification"),
128 },
129 {
130 ID: auth0.String("some-id-2"),
131 Domain: auth0.String("some-domain-2"),
132 Status: auth0.String("ready"),
133 },
134 },
135 assertOutput: func(t testing.TB, options pickerOptions) {
136 assert.Len(t, options, 2)
137 assert.Equal(t, "some-domain-1 (some-id-1)", options[0].label)
138 assert.Equal(t, "some-id-1", options[0].value)
139 assert.Equal(t, "some-domain-2 (some-id-2)", options[1].label)
140 assert.Equal(t, "some-id-2", options[1].value)
141 },
142 assertError: func(t testing.TB, err error) {
143 t.Fail()
144 },
145 },

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected