MCPcopy Index your code
hub / github.com/coder/coder / TestDeleteOrganizationsByUser

Function TestDeleteOrganizationsByUser

enterprise/coderd/organizations_test.go:153–212  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

151}
152
153func TestDeleteOrganizationsByUser(t *testing.T) {
154 t.Parallel()
155 t.Run("Default", func(t *testing.T) {
156 t.Parallel()
157 client, user := coderdenttest.New(t, &coderdenttest.Options{
158 LicenseOptions: &coderdenttest.LicenseOptions{
159 Features: license.Features{
160 codersdk.FeatureMultipleOrganizations: 1,
161 },
162 },
163 })
164 ctx := testutil.Context(t, testutil.WaitMedium)
165
166 // nolint:gocritic // owner used below to delete
167 o, err := client.Organization(ctx, user.OrganizationID)
168 require.NoError(t, err)
169
170 // nolint:gocritic // only owners can delete orgs
171 err = client.DeleteOrganization(ctx, o.ID.String())
172 var apiErr *codersdk.Error
173 require.ErrorAs(t, err, &apiErr)
174 require.Equal(t, http.StatusBadRequest, apiErr.StatusCode())
175 })
176
177 t.Run("DeleteById", func(t *testing.T) {
178 t.Parallel()
179 client, _ := coderdenttest.New(t, &coderdenttest.Options{
180 LicenseOptions: &coderdenttest.LicenseOptions{
181 Features: license.Features{
182 codersdk.FeatureMultipleOrganizations: 1,
183 },
184 },
185 })
186 ctx := testutil.Context(t, testutil.WaitMedium)
187
188 o := coderdenttest.CreateOrganization(t, client, coderdenttest.CreateOrganizationOptions{})
189
190 // nolint:gocritic // only owners can delete orgs
191 err := client.DeleteOrganization(ctx, o.ID.String())
192 require.NoError(t, err)
193 })
194
195 t.Run("DeleteByName", func(t *testing.T) {
196 t.Parallel()
197 client, _ := coderdenttest.New(t, &coderdenttest.Options{
198 LicenseOptions: &coderdenttest.LicenseOptions{
199 Features: license.Features{
200 codersdk.FeatureMultipleOrganizations: 1,
201 },
202 },
203 })
204 ctx := testutil.Context(t, testutil.WaitMedium)
205
206 o := coderdenttest.CreateOrganization(t, client, coderdenttest.CreateOrganizationOptions{})
207
208 // nolint:gocritic // only owners can delete orgs
209 err := client.DeleteOrganization(ctx, o.Name)
210 require.NoError(t, err)

Callers

nothing calls this directly

Calls 9

StatusCodeMethod · 0.95
NewFunction · 0.92
ContextFunction · 0.92
CreateOrganizationFunction · 0.92
RunMethod · 0.65
OrganizationMethod · 0.45
DeleteOrganizationMethod · 0.45
StringMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected