(ctx context.Context, t *testing.T, client *codersdk.Client, organizationID string, user string, consumed, total int)
| 36 | } |
| 37 | |
| 38 | func verifyQuotaUser(ctx context.Context, t *testing.T, client *codersdk.Client, organizationID string, user string, consumed, total int) { |
| 39 | t.Helper() |
| 40 | |
| 41 | got, err := client.WorkspaceQuota(ctx, organizationID, user) |
| 42 | require.NoError(t, err) |
| 43 | require.EqualValues(t, codersdk.WorkspaceQuota{ |
| 44 | Budget: total, |
| 45 | CreditsConsumed: consumed, |
| 46 | }, got) |
| 47 | |
| 48 | // Remove this check when the deprecated endpoint is removed. |
| 49 | // This just makes sure the deprecated endpoint is still working |
| 50 | // as intended. It will only work for the default organization. |
| 51 | deprecatedGot, err := deprecatedQuotaEndpoint(ctx, client, user) |
| 52 | require.NoError(t, err, "deprecated endpoint") |
| 53 | // Only continue to check if the values differ |
| 54 | if deprecatedGot.Budget != got.Budget || deprecatedGot.CreditsConsumed != got.CreditsConsumed { |
| 55 | org, err := client.OrganizationByName(ctx, organizationID) |
| 56 | if err != nil { |
| 57 | return |
| 58 | } |
| 59 | if org.IsDefault { |
| 60 | require.Equal(t, got, deprecatedGot) |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | func TestWorkspaceQuota(t *testing.T) { |
| 66 | t.Parallel() |
no test coverage detected