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

Function TestPatchOrganizationsByUser

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

Source from the content-addressed store, hash-verified

212}
213
214func TestPatchOrganizationsByUser(t *testing.T) {
215 t.Parallel()
216 t.Run("Conflict", func(t *testing.T) {
217 t.Parallel()
218 client, user := coderdenttest.New(t, &coderdenttest.Options{
219 LicenseOptions: &coderdenttest.LicenseOptions{
220 Features: license.Features{
221 codersdk.FeatureMultipleOrganizations: 1,
222 },
223 },
224 })
225 ctx := testutil.Context(t, testutil.WaitMedium)
226
227 // nolint:gocritic // owner used below as only they can create orgs
228 originalOrg, err := client.Organization(ctx, user.OrganizationID)
229 require.NoError(t, err)
230
231 o := coderdenttest.CreateOrganization(t, client, coderdenttest.CreateOrganizationOptions{})
232
233 // nolint:gocritic // owner used above to make the org
234 _, err = client.UpdateOrganization(ctx, o.ID.String(), codersdk.UpdateOrganizationRequest{
235 Name: originalOrg.Name,
236 })
237 var apiErr *codersdk.Error
238 require.ErrorAs(t, err, &apiErr)
239 require.Equal(t, http.StatusConflict, apiErr.StatusCode())
240 })
241
242 t.Run("ReservedName", func(t *testing.T) {
243 t.Parallel()
244 client, _ := coderdenttest.New(t, &coderdenttest.Options{
245 LicenseOptions: &coderdenttest.LicenseOptions{
246 Features: license.Features{
247 codersdk.FeatureMultipleOrganizations: 1,
248 },
249 },
250 })
251 ctx := testutil.Context(t, testutil.WaitMedium)
252
253 var err error
254 o := coderdenttest.CreateOrganization(t, client, coderdenttest.CreateOrganizationOptions{})
255
256 _, err = client.UpdateOrganization(ctx, o.ID.String(), codersdk.UpdateOrganizationRequest{
257 Name: codersdk.DefaultOrganization,
258 })
259 var apiErr *codersdk.Error
260 require.ErrorAs(t, err, &apiErr)
261 require.Equal(t, http.StatusBadRequest, apiErr.StatusCode())
262 })
263
264 t.Run("InvalidName", func(t *testing.T) {
265 t.Parallel()
266 client, _ := coderdenttest.New(t, &coderdenttest.Options{
267 LicenseOptions: &coderdenttest.LicenseOptions{
268 Features: license.Features{
269 codersdk.FeatureMultipleOrganizations: 1,
270 },
271 },

Callers

nothing calls this directly

Calls 12

StatusCodeMethod · 0.95
NewFunction · 0.92
ContextFunction · 0.92
CreateOrganizationFunction · 0.92
RefFunction · 0.92
LicensesMethod · 0.80
RunMethod · 0.65
UpdateOrganizationMethod · 0.65
DeleteLicenseMethod · 0.65
OrganizationMethod · 0.45
StringMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected