(t *testing.T)
| 212 | } |
| 213 | |
| 214 | func 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 | }, |
nothing calls this directly
no test coverage detected