Skip to content

Commit

Permalink
[usage] Cleanup usage records after test
Browse files Browse the repository at this point in the history
  • Loading branch information
easyCZ authored and roboquat committed Sep 6, 2022
1 parent d70b54d commit 3328f57
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion components/usage/pkg/apiv1/usage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,10 @@ func TestUsageService_ReconcileUsageWithLedger(t *testing.T) {
to := time.Date(2022, 05, 1, 1, 00, 00, 00, time.UTC)
attributionID := db.NewTeamAttributionID(uuid.New().String())

t.Cleanup(func() {
require.NoError(t, dbconn.Where("attributionId = ?", attributionID).Delete(&db.Usage{}).Error)
})

// stopped instances
instance := dbtest.NewWorkspaceInstance(t, db.WorkspaceInstance{
UsageAttributionID: attributionID,
Expand All @@ -572,7 +576,9 @@ func TestUsageService_ReconcileUsageWithLedger(t *testing.T) {
dbtest.CreateWorkspaceInstances(t, dbconn, instance)

// running instances
dbtest.CreateWorkspaceInstances(t, dbconn, dbtest.NewWorkspaceInstance(t, db.WorkspaceInstance{}))
dbtest.CreateWorkspaceInstances(t, dbconn, dbtest.NewWorkspaceInstance(t, db.WorkspaceInstance{
UsageAttributionID: attributionID,
}))

// usage drafts
dbtest.CreateUsageRecords(t, dbconn, dbtest.NewUsage(t, db.Usage{
Expand Down

0 comments on commit 3328f57

Please sign in to comment.