(t *testing.T)
| 151 | } |
| 152 | |
| 153 | func 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) |
nothing calls this directly
no test coverage detected