99 "testing"
1010 "time"
1111
12- common_db "github.com/gitpod-io/gitpod/common-go/db "
13- "github.com/gitpod-io/gitpod/usage/pkg/db"
14- "github.com/gitpod-io/gitpod/usage/pkg/db /dbtest"
12+ db "github.com/gitpod-io/gitpod/components/gitpod-db/go "
13+
14+ "github.com/gitpod-io/gitpod/components/gitpod-db/go /dbtest"
1515 "github.com/google/uuid"
1616 "github.com/stretchr/testify/require"
1717 "google.golang.org/grpc/codes"
@@ -73,28 +73,28 @@ func TestCostCenterManager_GetOrCreateCostCenter_ResetsExpired(t *testing.T) {
7373
7474 expiredCC := db.CostCenter {
7575 ID : db .NewTeamAttributionID (uuid .New ().String ()),
76- CreationTime : common_db .NewVarCharTime (now ),
76+ CreationTime : db .NewVarCharTime (now ),
7777 SpendingLimit : 0 ,
7878 BillingStrategy : db .CostCenter_Other ,
79- NextBillingTime : common_db .NewVarCharTime (expired ),
80- BillingCycleStart : common_db .NewVarCharTime (now ),
79+ NextBillingTime : db .NewVarCharTime (expired ),
80+ BillingCycleStart : db .NewVarCharTime (now ),
8181 }
8282 unexpiredCC := db.CostCenter {
8383 ID : db .NewUserAttributionID (uuid .New ().String ()),
84- CreationTime : common_db .NewVarCharTime (now ),
84+ CreationTime : db .NewVarCharTime (now ),
8585 SpendingLimit : 500 ,
8686 BillingStrategy : db .CostCenter_Other ,
87- NextBillingTime : common_db .NewVarCharTime (unexpired ),
88- BillingCycleStart : common_db .NewVarCharTime (now ),
87+ NextBillingTime : db .NewVarCharTime (unexpired ),
88+ BillingCycleStart : db .NewVarCharTime (now ),
8989 }
9090 // Stripe billing strategy should not be reset
9191 stripeCC := db.CostCenter {
9292 ID : db .NewUserAttributionID (uuid .New ().String ()),
93- CreationTime : common_db .NewVarCharTime (now ),
93+ CreationTime : db .NewVarCharTime (now ),
9494 SpendingLimit : 0 ,
9595 BillingStrategy : db .CostCenter_Stripe ,
96- NextBillingTime : common_db .VarcharTime {},
97- BillingCycleStart : common_db .NewVarCharTime (now ),
96+ NextBillingTime : db .VarcharTime {},
97+ BillingCycleStart : db .NewVarCharTime (now ),
9898 }
9999
100100 dbtest .CreateCostCenters (t , conn ,
@@ -103,21 +103,21 @@ func TestCostCenterManager_GetOrCreateCostCenter_ResetsExpired(t *testing.T) {
103103 dbtest .NewCostCenter (t , stripeCC ),
104104 )
105105
106- // expired CostCenter should be reset, so we get a new CreationTime
106+ // expired db. CostCenter should be reset, so we get a new CreationTime
107107 retrievedExpiredCC , err := mnr .GetOrCreateCostCenter (context .Background (), expiredCC .ID )
108108 require .NoError (t , err )
109109 t .Cleanup (func () {
110110 conn .Model (& db.CostCenter {}).Delete (retrievedExpiredCC .ID )
111111 })
112- require .Equal (t , common_db .NewVarCharTime (expired ).Time ().AddDate (0 , 1 , 0 ), retrievedExpiredCC .NextBillingTime .Time ())
112+ require .Equal (t , db .NewVarCharTime (expired ).Time ().AddDate (0 , 1 , 0 ), retrievedExpiredCC .NextBillingTime .Time ())
113113 require .Equal (t , expiredCC .ID , retrievedExpiredCC .ID )
114114 require .Equal (t , expiredCC .BillingStrategy , retrievedExpiredCC .BillingStrategy )
115115 require .WithinDuration (t , now , expiredCC .CreationTime .Time (), 3 * time .Second , "new cost center creation time must be within 3 seconds of now" )
116116
117117 // unexpired cost center must not be reset
118118 retrievedUnexpiredCC , err := mnr .GetOrCreateCostCenter (context .Background (), unexpiredCC .ID )
119119 require .NoError (t , err )
120- require .Equal (t , common_db .NewVarCharTime (unexpired ).Time (), retrievedUnexpiredCC .NextBillingTime .Time ())
120+ require .Equal (t , db .NewVarCharTime (unexpired ).Time (), retrievedUnexpiredCC .NextBillingTime .Time ())
121121 require .Equal (t , unexpiredCC .ID , retrievedUnexpiredCC .ID )
122122 require .Equal (t , unexpiredCC .BillingStrategy , retrievedUnexpiredCC .BillingStrategy )
123123 require .WithinDuration (t , unexpiredCC .CreationTime .Time (), retrievedUnexpiredCC .CreationTime .Time (), 100 * time .Millisecond )
@@ -341,16 +341,16 @@ func TestCostCenter_ListLatestCostCentersWithBillingTimeBefore(t *testing.T) {
341341 dbtest .NewCostCenter (t , db.CostCenter {
342342 ID : db .NewTeamAttributionID (attributionID ),
343343 SpendingLimit : 100 ,
344- CreationTime : common_db .NewVarCharTime (firstCreation ),
344+ CreationTime : db .NewVarCharTime (firstCreation ),
345345 BillingStrategy : db .CostCenter_Other ,
346- NextBillingTime : common_db .NewVarCharTime (firstCreation ),
346+ NextBillingTime : db .NewVarCharTime (firstCreation ),
347347 }),
348348 dbtest .NewCostCenter (t , db.CostCenter {
349349 ID : db .NewTeamAttributionID (attributionID ),
350350 SpendingLimit : 100 ,
351- CreationTime : common_db .NewVarCharTime (secondCreation ),
351+ CreationTime : db .NewVarCharTime (secondCreation ),
352352 BillingStrategy : db .CostCenter_Other ,
353- NextBillingTime : common_db .NewVarCharTime (secondCreation ),
353+ NextBillingTime : db .NewVarCharTime (secondCreation ),
354354 }),
355355 }
356356
@@ -378,14 +378,14 @@ func TestCostCenter_ListLatestCostCentersWithBillingTimeBefore(t *testing.T) {
378378 dbtest .NewCostCenter (t , db.CostCenter {
379379 ID : db .NewTeamAttributionID (attributionID ),
380380 SpendingLimit : 100 ,
381- CreationTime : common_db .NewVarCharTime (firstCreation ),
381+ CreationTime : db .NewVarCharTime (firstCreation ),
382382 BillingStrategy : db .CostCenter_Other ,
383- NextBillingTime : common_db .NewVarCharTime (firstCreation ),
383+ NextBillingTime : db .NewVarCharTime (firstCreation ),
384384 }),
385385 dbtest .NewCostCenter (t , db.CostCenter {
386386 ID : db .NewTeamAttributionID (attributionID ),
387387 SpendingLimit : 100 ,
388- CreationTime : common_db .NewVarCharTime (secondCreation ),
388+ CreationTime : db .NewVarCharTime (secondCreation ),
389389 BillingStrategy : db .CostCenter_Stripe ,
390390 }),
391391 }
@@ -410,7 +410,7 @@ func TestCostCenterManager_ResetUsage(t *testing.T) {
410410 })
411411 _ , err := mnr .ResetUsage (context .Background (), db.CostCenter {
412412 ID : db .NewUserAttributionID (uuid .New ().String ()),
413- CreationTime : common_db .NewVarCharTime (time .Now ()),
413+ CreationTime : db .NewVarCharTime (time .Now ()),
414414 SpendingLimit : 500 ,
415415 BillingStrategy : db .CostCenter_Stripe ,
416416 })
@@ -425,10 +425,10 @@ func TestCostCenterManager_ResetUsage(t *testing.T) {
425425 })
426426 oldCC := db.CostCenter {
427427 ID : db .NewTeamAttributionID (uuid .New ().String ()),
428- CreationTime : common_db .NewVarCharTime (time .Now ()),
428+ CreationTime : db .NewVarCharTime (time .Now ()),
429429 SpendingLimit : 0 ,
430430 BillingStrategy : db .CostCenter_Other ,
431- NextBillingTime : common_db .NewVarCharTime (ts ),
431+ NextBillingTime : db .NewVarCharTime (ts ),
432432 }
433433 newCC , err := mnr .ResetUsage (context .Background (), oldCC )
434434 require .NoError (t , err )
0 commit comments