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

Function verifyQuotaUser

enterprise/coderd/workspacequota_test.go:38–63  ·  view source on GitHub ↗
(ctx context.Context, t *testing.T, client *codersdk.Client, organizationID string, user string, consumed, total int)

Source from the content-addressed store, hash-verified

36}
37
38func 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
65func TestWorkspaceQuota(t *testing.T) {
66 t.Parallel()

Callers 2

verifyQuotaFunction · 0.85
TestWorkspaceQuotaFunction · 0.85

Calls 5

deprecatedQuotaEndpointFunction · 0.85
WorkspaceQuotaMethod · 0.80
OrganizationByNameMethod · 0.80
HelperMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected