From 4327aebfc0a2bc4f0b3708ef7be57292b867ce9c Mon Sep 17 00:00:00 2001 From: Paul Nicolas Date: Tue, 24 Sep 2024 16:28:28 +0200 Subject: [PATCH] fix time test storage --- .../internal/storage/accounts_test.go | 14 +-- .../internal/storage/balances_test.go | 114 +++++++++--------- .../internal/storage/bank_accounts_test.go | 32 ++--- .../internal/storage/connectors_test.go | 12 +- .../internal/storage/payments_test.go | 50 ++++---- .../payments/internal/storage/pools_test.go | 8 +- .../internal/storage/schedules_test.go | 10 +- .../storage/workflow_instances_test.go | 20 +-- 8 files changed, 130 insertions(+), 130 deletions(-) diff --git a/components/payments/internal/storage/accounts_test.go b/components/payments/internal/storage/accounts_test.go index b51a620262..b07e36f701 100644 --- a/components/payments/internal/storage/accounts_test.go +++ b/components/payments/internal/storage/accounts_test.go @@ -3,12 +3,12 @@ package storage import ( "context" "testing" - "time" "github.com/formancehq/go-libs/bun/bunpaginate" "github.com/formancehq/go-libs/logging" "github.com/formancehq/go-libs/pointer" "github.com/formancehq/go-libs/query" + "github.com/formancehq/go-libs/time" "github.com/formancehq/payments/internal/models" "github.com/google/uuid" "github.com/stretchr/testify/require" @@ -23,7 +23,7 @@ var ( }, ConnectorID: defaultConnector.ID, Reference: "test1", - CreatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, Type: models.ACCOUNT_TYPE_INTERNAL, Name: pointer.For("test1"), DefaultAsset: pointer.For("USD/2"), @@ -39,7 +39,7 @@ var ( }, ConnectorID: defaultConnector.ID, Reference: "test2", - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, Type: models.ACCOUNT_TYPE_INTERNAL, Metadata: map[string]string{ "foo2": "bar2", @@ -53,7 +53,7 @@ var ( }, ConnectorID: defaultConnector.ID, Reference: "test3", - CreatedAt: now.Add(-45 * time.Minute).UTC(), + CreatedAt: now.Add(-45 * time.Minute).UTC().Time, Type: models.ACCOUNT_TYPE_EXTERNAL, Name: pointer.For("test3"), Metadata: map[string]string{ @@ -71,7 +71,7 @@ var ( }, ConnectorID: defaultConnector2.ID, Reference: "test1", - CreatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, Type: models.ACCOUNT_TYPE_INTERNAL, Name: pointer.For("test1"), DefaultAsset: pointer.For("USD/2"), @@ -110,7 +110,7 @@ func TestAccountsUpsert(t *testing.T) { ID: id, ConnectorID: defaultConnector.ID, Reference: "test1", - CreatedAt: now.Add(-12 * time.Minute), + CreatedAt: now.Add(-12 * time.Minute).UTC().Time, Type: models.ACCOUNT_TYPE_EXTERNAL, Name: pointer.For("changed"), DefaultAsset: pointer.For("EUR"), @@ -145,7 +145,7 @@ func TestAccountsUpsert(t *testing.T) { }, ConnectorID: unknownConnectorID, Reference: "test_unknown", - CreatedAt: now.Add(-12 * time.Minute), + CreatedAt: now.Add(-12 * time.Minute).UTC().Time, Type: models.ACCOUNT_TYPE_EXTERNAL, Name: pointer.For("changed"), DefaultAsset: pointer.For("EUR"), diff --git a/components/payments/internal/storage/balances_test.go b/components/payments/internal/storage/balances_test.go index f49a7b4e95..9f19a01ed4 100644 --- a/components/payments/internal/storage/balances_test.go +++ b/components/payments/internal/storage/balances_test.go @@ -4,11 +4,11 @@ import ( "context" "math/big" "testing" - "time" "github.com/formancehq/go-libs/bun/bunpaginate" "github.com/formancehq/go-libs/logging" "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/time" "github.com/formancehq/payments/internal/models" "github.com/google/uuid" "github.com/stretchr/testify/require" @@ -18,22 +18,22 @@ var ( defaultBalances = []models.Balance{ { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-60 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-60 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(100), }, { AccountID: defaultAccounts[1].ID, - CreatedAt: now.Add(-30 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-30 * time.Minute).UTC().Time, Asset: "EUR/2", Balance: big.NewInt(1000), }, { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-55 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-55 * time.Minute).UTC().Time, Asset: "EUR/2", Balance: big.NewInt(150), }, @@ -42,15 +42,15 @@ var ( defaultBalances2 = []models.Balance{ { AccountID: defaultAccounts[2].ID, - CreatedAt: now.Add(-59 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-59 * time.Minute).UTC(), + CreatedAt: now.Add(-59 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-59 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(100), }, { AccountID: defaultAccounts[2].ID, - CreatedAt: now.Add(-31 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-31 * time.Minute).UTC(), + CreatedAt: now.Add(-31 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-31 * time.Minute).UTC().Time, Asset: "DKK/2", Balance: big.NewInt(1000), }, @@ -77,8 +77,8 @@ func TestBalancesUpsert(t *testing.T) { b := models.Balance{ AccountID: defaultAccounts[2].ID, - CreatedAt: now.Add(-20 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-20 * time.Minute).UTC(), + CreatedAt: now.Add(-20 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-20 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(100), } @@ -95,8 +95,8 @@ func TestBalancesUpsert(t *testing.T) { expectedBalances := []models.Balance{ { AccountID: defaultAccounts[2].ID, - CreatedAt: now.Add(-59 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-20 * time.Minute).UTC(), + CreatedAt: now.Add(-59 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-20 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(100), }, @@ -113,8 +113,8 @@ func TestBalancesUpsert(t *testing.T) { b := models.Balance{ AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-20 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-20 * time.Minute).UTC(), + CreatedAt: now.Add(-20 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-20 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(200), } @@ -130,15 +130,15 @@ func TestBalancesUpsert(t *testing.T) { expectedBalances := []models.Balance{ { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-20 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-20 * time.Minute).UTC(), + CreatedAt: now.Add(-20 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-20 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(200), }, { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-60 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-20 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-20 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(100), }, @@ -155,8 +155,8 @@ func TestBalancesUpsert(t *testing.T) { b := models.Balance{ AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-10 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-10 * time.Minute).UTC(), + CreatedAt: now.Add(-10 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-10 * time.Minute).UTC().Time, Asset: "DKK/2", Balance: big.NewInt(200), } @@ -172,22 +172,22 @@ func TestBalancesUpsert(t *testing.T) { expectedBalances := []models.Balance{ { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-10 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-10 * time.Minute).UTC(), + CreatedAt: now.Add(-10 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-10 * time.Minute).UTC().Time, Asset: "DKK/2", Balance: big.NewInt(200), }, { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-55 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-55 * time.Minute).UTC().Time, Asset: "EUR/2", Balance: big.NewInt(150), }, { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-60 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-60 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(100), }, @@ -258,15 +258,15 @@ func TestBalancesList(t *testing.T) { expectedBalances := []models.Balance{ { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-55 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-55 * time.Minute).UTC().Time, Asset: "EUR/2", Balance: big.NewInt(150), }, { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-60 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-60 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(100), }, @@ -291,15 +291,15 @@ func TestBalancesList(t *testing.T) { expectedBalances := []models.Balance{ { AccountID: defaultAccounts[2].ID, - CreatedAt: now.Add(-59 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-59 * time.Minute).UTC(), + CreatedAt: now.Add(-59 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-59 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(100), }, { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-60 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-60 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(100), }, @@ -324,8 +324,8 @@ func TestBalancesList(t *testing.T) { expectedBalances := []models.Balance{ { AccountID: defaultAccounts[2].ID, - CreatedAt: now.Add(-30 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-30 * time.Minute).UTC().Time, Asset: "DKK/2", Balance: big.NewInt(1000), }, @@ -343,22 +343,22 @@ func TestBalancesList(t *testing.T) { q := NewListBalancesQuery( bunpaginate.NewPaginatedQueryOptions(BalanceQuery{ - From: now.Add(-40 * time.Minute), + From: now.Add(-40 * time.Minute).UTC().Time, }).WithPageSize(15), ) expectedBalances := []models.Balance{ { AccountID: defaultAccounts[1].ID, - CreatedAt: now.Add(-30 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-30 * time.Minute).UTC().Time, Asset: "EUR/2", Balance: big.NewInt(1000), }, { AccountID: defaultAccounts[2].ID, - CreatedAt: now.Add(-31 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-31 * time.Minute).UTC(), + CreatedAt: now.Add(-31 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-31 * time.Minute).UTC().Time, Asset: "DKK/2", Balance: big.NewInt(1000), }, @@ -376,7 +376,7 @@ func TestBalancesList(t *testing.T) { q := NewListBalancesQuery( bunpaginate.NewPaginatedQueryOptions(BalanceQuery{ - From: now.Add(-20 * time.Minute), + From: now.Add(-20 * time.Minute).UTC().Time, }).WithPageSize(15), ) @@ -391,29 +391,29 @@ func TestBalancesList(t *testing.T) { q := NewListBalancesQuery( bunpaginate.NewPaginatedQueryOptions(BalanceQuery{ - To: now.Add(-40 * time.Minute), + To: now.Add(-40 * time.Minute).UTC().Time, }).WithPageSize(15), ) expectedBalances := []models.Balance{ { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-55 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-55 * time.Minute).UTC().Time, Asset: "EUR/2", Balance: big.NewInt(150), }, { AccountID: defaultAccounts[2].ID, - CreatedAt: now.Add(-59 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-59 * time.Minute).UTC(), + CreatedAt: now.Add(-59 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-59 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(100), }, { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-60 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-60 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(100), }, @@ -431,7 +431,7 @@ func TestBalancesList(t *testing.T) { q := NewListBalancesQuery( bunpaginate.NewPaginatedQueryOptions(BalanceQuery{ - To: now.Add(-70 * time.Minute), + To: now.Add(-70 * time.Minute).UTC().Time, }).WithPageSize(15), ) @@ -453,8 +453,8 @@ func TestBalancesList(t *testing.T) { expectedBalances1 := []models.Balance{ { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-55 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-55 * time.Minute).UTC().Time, Asset: "EUR/2", Balance: big.NewInt(150), }, @@ -471,8 +471,8 @@ func TestBalancesList(t *testing.T) { expectedBalances2 := []models.Balance{ { AccountID: defaultAccounts[0].ID, - CreatedAt: now.Add(-60 * time.Minute).UTC(), - LastUpdatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, + LastUpdatedAt: now.Add(-60 * time.Minute).UTC().Time, Asset: "USD/2", Balance: big.NewInt(100), }, diff --git a/components/payments/internal/storage/bank_accounts_test.go b/components/payments/internal/storage/bank_accounts_test.go index b0f490d897..1e1551e9e1 100644 --- a/components/payments/internal/storage/bank_accounts_test.go +++ b/components/payments/internal/storage/bank_accounts_test.go @@ -17,7 +17,7 @@ import ( var ( defaultBankAccount = models.BankAccount{ ID: uuid.New(), - CreatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, Name: "test1", AccountNumber: pointer.For("12345678"), Country: pointer.For("US"), @@ -29,7 +29,7 @@ var ( bcID2 = uuid.New() defaultBankAccount2 = models.BankAccount{ ID: bcID2, - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, Name: "test2", IBAN: pointer.For("DE89370400440532013000"), SwiftBicCode: pointer.For("COBADEFFXXX"), @@ -42,7 +42,7 @@ var ( BankAccountID: bcID2, AccountID: defaultAccounts[0].ID, ConnectorID: defaultConnector.ID, - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, }, }, } @@ -50,7 +50,7 @@ var ( // No metadata defaultBankAccount3 = models.BankAccount{ ID: uuid.New(), - CreatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, Name: "test1", AccountNumber: pointer.For("12345678"), Country: pointer.For("US"), @@ -77,7 +77,7 @@ func TestBankAccountsUpsert(t *testing.T) { ba := models.BankAccount{ ID: defaultBankAccount.ID, - CreatedAt: now.UTC(), + CreatedAt: now.UTC().Time, Name: "changed", AccountNumber: pointer.For("987654321"), Country: pointer.For("CA"), @@ -99,7 +99,7 @@ func TestBankAccountsUpsert(t *testing.T) { ba := models.BankAccount{ ID: uuid.New(), - CreatedAt: now.UTC(), + CreatedAt: now.UTC().Time, Name: "foo", AccountNumber: pointer.For("12345678"), Country: pointer.For("US"), @@ -114,7 +114,7 @@ func TestBankAccountsUpsert(t *testing.T) { Reference: uuid.New(), Provider: "unknown", }, - CreatedAt: now.UTC(), + CreatedAt: now.UTC().Time, }, }, } @@ -248,7 +248,7 @@ func TestBankAccountsGet(t *testing.T) { acc := models.BankAccount{ ID: defaultBankAccount.ID, - CreatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, Name: "test1", Country: pointer.For("US"), Metadata: map[string]string{ @@ -266,7 +266,7 @@ func TestBankAccountsGet(t *testing.T) { acc := models.BankAccount{ ID: bcID2, - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, Name: "test2", Country: pointer.For("DE"), Metadata: map[string]string{ @@ -277,7 +277,7 @@ func TestBankAccountsGet(t *testing.T) { BankAccountID: bcID2, AccountID: defaultAccounts[0].ID, ConnectorID: defaultConnector.ID, - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, }, }, } @@ -545,7 +545,7 @@ func TestBankAccountsAddRelatedAccount(t *testing.T) { BankAccountID: defaultBankAccount.ID, AccountID: defaultAccounts[0].ID, ConnectorID: defaultConnector.ID, - CreatedAt: now.UTC(), + CreatedAt: now.UTC().Time, } ba := defaultBankAccount @@ -565,7 +565,7 @@ func TestBankAccountsAddRelatedAccount(t *testing.T) { BankAccountID: defaultBankAccount2.ID, AccountID: defaultAccounts[1].ID, ConnectorID: defaultConnector.ID, - CreatedAt: now.UTC(), + CreatedAt: now.UTC().Time, } ba := defaultBankAccount2 @@ -585,7 +585,7 @@ func TestBankAccountsAddRelatedAccount(t *testing.T) { BankAccountID: uuid.New(), AccountID: defaultAccounts[1].ID, ConnectorID: defaultConnector.ID, - CreatedAt: now.UTC(), + CreatedAt: now.UTC().Time, } require.Error(t, store.BankAccountsAddRelatedAccount(ctx, acc)) @@ -601,7 +601,7 @@ func TestBankAccountsAddRelatedAccount(t *testing.T) { ConnectorID: defaultConnector.ID, }, ConnectorID: defaultConnector.ID, - CreatedAt: now.UTC(), + CreatedAt: now.UTC().Time, } require.Error(t, store.BankAccountsAddRelatedAccount(ctx, acc)) @@ -617,7 +617,7 @@ func TestBankAccountsAddRelatedAccount(t *testing.T) { Reference: uuid.New(), Provider: "unknown", }, - CreatedAt: now.UTC(), + CreatedAt: now.UTC().Time, } require.Error(t, store.BankAccountsAddRelatedAccount(ctx, acc)) @@ -630,7 +630,7 @@ func TestBankAccountsAddRelatedAccount(t *testing.T) { BankAccountID: defaultBankAccount3.ID, AccountID: defaultAccounts[0].ID, ConnectorID: defaultConnector.ID, - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, } ba := defaultBankAccount3 diff --git a/components/payments/internal/storage/connectors_test.go b/components/payments/internal/storage/connectors_test.go index 23c69ef118..e06ca6c89e 100644 --- a/components/payments/internal/storage/connectors_test.go +++ b/components/payments/internal/storage/connectors_test.go @@ -3,11 +3,11 @@ package storage import ( "context" "testing" - "time" "github.com/formancehq/go-libs/bun/bunpaginate" "github.com/formancehq/go-libs/logging" "github.com/formancehq/go-libs/query" + "github.com/formancehq/go-libs/time" "github.com/formancehq/payments/internal/models" "github.com/google/uuid" "github.com/stretchr/testify/require" @@ -21,7 +21,7 @@ var ( Provider: "default", }, Name: "default", - CreatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, Provider: "default", Config: []byte(`{}`), } @@ -32,7 +32,7 @@ var ( Provider: "default2", }, Name: "default2", - CreatedAt: now.Add(-45 * time.Minute).UTC(), + CreatedAt: now.Add(-45 * time.Minute).UTC().Time, Provider: "default2", Config: []byte(`{}`), } @@ -43,7 +43,7 @@ var ( Provider: "default", }, Name: "default3", - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, Provider: "default", Config: []byte(`{}`), } @@ -68,7 +68,7 @@ func TestConnectorsInstall(t *testing.T) { c := models.Connector{ ID: defaultConnector.ID, Name: "test changed", - CreatedAt: time.Now().UTC(), + CreatedAt: time.Now().UTC().Time, Provider: "test", Config: []byte(`{}`), } @@ -90,7 +90,7 @@ func TestConnectorsInstall(t *testing.T) { Provider: "test", }, Name: "default", - CreatedAt: now.Add(-23 * time.Minute).UTC(), + CreatedAt: now.Add(-23 * time.Minute).UTC().Time, Provider: "test", Config: []byte(`{}`), } diff --git a/components/payments/internal/storage/payments_test.go b/components/payments/internal/storage/payments_test.go index 8a0a9e7918..8a6eed7a16 100644 --- a/components/payments/internal/storage/payments_test.go +++ b/components/payments/internal/storage/payments_test.go @@ -45,7 +45,7 @@ var ( ID: pID1, ConnectorID: defaultConnector.ID, Reference: "test1", - CreatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, Type: models.PAYMENT_TYPE_TRANSFER, InitialAmount: big.NewInt(100), Amount: big.NewInt(100), @@ -60,11 +60,11 @@ var ( { ID: models.PaymentAdjustmentID{ PaymentID: pID1, - CreatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_SUCCEEDED, }, PaymentID: pID1, - CreatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_SUCCEEDED, Amount: big.NewInt(100), Asset: pointer.For("USD/2"), @@ -76,7 +76,7 @@ var ( ID: pid2, ConnectorID: defaultConnector.ID, Reference: "test2", - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, Type: models.PAYMENT_TYPE_PAYIN, InitialAmount: big.NewInt(200), Amount: big.NewInt(200), @@ -87,11 +87,11 @@ var ( { ID: models.PaymentAdjustmentID{ PaymentID: pid2, - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_FAILED, }, PaymentID: pid2, - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_FAILED, Amount: big.NewInt(200), Asset: pointer.For("EUR/2"), @@ -103,7 +103,7 @@ var ( ID: pid3, ConnectorID: defaultConnector.ID, Reference: "test3", - CreatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, Type: models.PAYMENT_TYPE_PAYOUT, InitialAmount: big.NewInt(300), Amount: big.NewInt(300), @@ -114,11 +114,11 @@ var ( { ID: models.PaymentAdjustmentID{ PaymentID: pid3, - CreatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_PENDING, }, PaymentID: pid3, - CreatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_PENDING, Amount: big.NewInt(300), Asset: pointer.For("DKK/2"), @@ -185,7 +185,7 @@ func TestPaymentsUpsert(t *testing.T) { ID: pid3, ConnectorID: defaultConnector.ID, Reference: "test3", - CreatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, Type: models.PAYMENT_TYPE_PAYOUT, InitialAmount: big.NewInt(300), Amount: big.NewInt(300), @@ -196,11 +196,11 @@ func TestPaymentsUpsert(t *testing.T) { { ID: models.PaymentAdjustmentID{ PaymentID: pid3, - CreatedAt: now.Add(-45 * time.Minute).UTC(), + CreatedAt: now.Add(-45 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_SUCCEEDED, }, PaymentID: pid3, - CreatedAt: now.Add(-45 * time.Minute).UTC(), + CreatedAt: now.Add(-45 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_SUCCEEDED, Amount: big.NewInt(300), Asset: pointer.For("DKK/2"), @@ -210,11 +210,11 @@ func TestPaymentsUpsert(t *testing.T) { { ID: models.PaymentAdjustmentID{ PaymentID: pid3, - CreatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_PENDING, }, PaymentID: pid3, - CreatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_PENDING, Amount: big.NewInt(300), Asset: pointer.For("DKK/2"), @@ -237,7 +237,7 @@ func TestPaymentsUpsert(t *testing.T) { ID: pID1, ConnectorID: defaultConnector.ID, Reference: "test1", - CreatedAt: now.Add(-20 * time.Minute).UTC(), + CreatedAt: now.Add(-20 * time.Minute).UTC().Time, Type: models.PAYMENT_TYPE_TRANSFER, InitialAmount: big.NewInt(100), Amount: big.NewInt(100), @@ -247,11 +247,11 @@ func TestPaymentsUpsert(t *testing.T) { { ID: models.PaymentAdjustmentID{ PaymentID: pID1, - CreatedAt: now.Add(-20 * time.Minute).UTC(), + CreatedAt: now.Add(-20 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_REFUNDED, }, PaymentID: pID1, - CreatedAt: now.Add(-20 * time.Minute).UTC(), + CreatedAt: now.Add(-20 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_REFUNDED, Amount: big.NewInt(50), Asset: pointer.For("USD/2"), @@ -269,7 +269,7 @@ func TestPaymentsUpsert(t *testing.T) { ID: pID1, ConnectorID: defaultConnector.ID, Reference: "test1", - CreatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, Type: models.PAYMENT_TYPE_TRANSFER, InitialAmount: big.NewInt(100), Amount: big.NewInt(50), @@ -285,11 +285,11 @@ func TestPaymentsUpsert(t *testing.T) { { ID: models.PaymentAdjustmentID{ PaymentID: pID1, - CreatedAt: now.Add(-20 * time.Minute).UTC(), + CreatedAt: now.Add(-20 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_REFUNDED, }, PaymentID: pID1, - CreatedAt: now.Add(-20 * time.Minute).UTC(), + CreatedAt: now.Add(-20 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_REFUNDED, Amount: big.NewInt(50), Asset: pointer.For("USD/2"), @@ -298,11 +298,11 @@ func TestPaymentsUpsert(t *testing.T) { { ID: models.PaymentAdjustmentID{ PaymentID: pID1, - CreatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_SUCCEEDED, }, PaymentID: pID1, - CreatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, Status: models.PAYMENT_STATUS_SUCCEEDED, Amount: big.NewInt(100), Asset: pointer.For("USD/2"), @@ -459,7 +459,7 @@ func TestPaymentsList(t *testing.T) { ID: pID1, ConnectorID: defaultConnector.ID, Reference: "test1", - CreatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, Type: models.PAYMENT_TYPE_TRANSFER, InitialAmount: big.NewInt(100), Amount: big.NewInt(100), @@ -476,7 +476,7 @@ func TestPaymentsList(t *testing.T) { ID: pid2, ConnectorID: defaultConnector.ID, Reference: "test2", - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, Type: models.PAYMENT_TYPE_PAYIN, InitialAmount: big.NewInt(200), Amount: big.NewInt(200), @@ -489,7 +489,7 @@ func TestPaymentsList(t *testing.T) { ID: pid3, ConnectorID: defaultConnector.ID, Reference: "test3", - CreatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, Type: models.PAYMENT_TYPE_PAYOUT, InitialAmount: big.NewInt(300), Amount: big.NewInt(300), diff --git a/components/payments/internal/storage/pools_test.go b/components/payments/internal/storage/pools_test.go index dc8da209e8..8237f2dcba 100644 --- a/components/payments/internal/storage/pools_test.go +++ b/components/payments/internal/storage/pools_test.go @@ -21,7 +21,7 @@ var ( { ID: poolID1, Name: "test1", - CreatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, PoolAccounts: []models.PoolAccounts{ { PoolID: poolID1, @@ -36,7 +36,7 @@ var ( { ID: poolID2, Name: "test2", - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, PoolAccounts: []models.PoolAccounts{ { PoolID: poolID2, @@ -47,7 +47,7 @@ var ( { ID: poolID3, Name: "test3", - CreatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, PoolAccounts: []models.PoolAccounts{ { PoolID: poolID3, @@ -78,7 +78,7 @@ func TestPoolsUpsert(t *testing.T) { p := models.Pool{ ID: poolID3, Name: "test1", - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, PoolAccounts: []models.PoolAccounts{ { PoolID: poolID3, diff --git a/components/payments/internal/storage/schedules_test.go b/components/payments/internal/storage/schedules_test.go index bafda005b3..1ac0be01e5 100644 --- a/components/payments/internal/storage/schedules_test.go +++ b/components/payments/internal/storage/schedules_test.go @@ -18,17 +18,17 @@ var ( { ID: "test1", ConnectorID: defaultConnector.ID, - CreatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, }, { ID: "test2", ConnectorID: defaultConnector.ID, - CreatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, }, { ID: "test3", ConnectorID: defaultConnector.ID, - CreatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, }, } ) @@ -52,7 +52,7 @@ func TestSchedulesUpsert(t *testing.T) { sch := models.Schedule{ ID: "test1", ConnectorID: defaultConnector.ID, - CreatedAt: now.Add(-90 * time.Minute), + CreatedAt: now.Add(-90 * time.Minute).UTC().Time, } require.NoError(t, store.SchedulesUpsert(ctx, sch)) @@ -69,7 +69,7 @@ func TestSchedulesUpsert(t *testing.T) { Reference: uuid.New(), Provider: "unknown", }, - CreatedAt: now.Add(-90 * time.Minute), + CreatedAt: now.Add(-90 * time.Minute).UTC().Time, } require.Error(t, store.SchedulesUpsert(ctx, sch)) diff --git a/components/payments/internal/storage/workflow_instances_test.go b/components/payments/internal/storage/workflow_instances_test.go index e5db2dbc6a..d379f0be81 100644 --- a/components/payments/internal/storage/workflow_instances_test.go +++ b/components/payments/internal/storage/workflow_instances_test.go @@ -20,26 +20,26 @@ var ( ID: "test1", ScheduleID: defaultSchedules[0].ID, ConnectorID: defaultConnector.ID, - CreatedAt: now.Add(-60 * time.Minute).UTC(), - UpdatedAt: now.Add(-60 * time.Minute).UTC(), + CreatedAt: now.Add(-60 * time.Minute).UTC().Time, + UpdatedAt: now.Add(-60 * time.Minute).UTC().Time, Terminated: false, }, { ID: "test2", ScheduleID: defaultSchedules[0].ID, ConnectorID: defaultConnector.ID, - CreatedAt: now.Add(-30 * time.Minute).UTC(), - UpdatedAt: now.Add(-30 * time.Minute).UTC(), + CreatedAt: now.Add(-30 * time.Minute).UTC().Time, + UpdatedAt: now.Add(-30 * time.Minute).UTC().Time, Terminated: false, }, { ID: "test3", ScheduleID: defaultSchedules[2].ID, ConnectorID: defaultConnector.ID, - CreatedAt: now.Add(-55 * time.Minute).UTC(), - UpdatedAt: now.Add(-55 * time.Minute).UTC(), + CreatedAt: now.Add(-55 * time.Minute).UTC().Time, + UpdatedAt: now.Add(-55 * time.Minute).UTC().Time, Terminated: true, - TerminatedAt: pointer.For(now.UTC()), + TerminatedAt: pointer.For(now.UTC().Time), Error: pointer.For("test error"), }, } @@ -68,7 +68,7 @@ func TestInstancesUpsert(t *testing.T) { instance := defaultWorkflowInstances[0] instance.Terminated = true - instance.TerminatedAt = &now + instance.TerminatedAt = pointer.For(now.UTC().Time) instance.Error = pointer.For("test error") upsertInstance(t, ctx, store, instance) @@ -122,7 +122,7 @@ func TestInstancesUpdate(t *testing.T) { instance := defaultWorkflowInstances[0] instance.Error = pointer.For("test error") instance.Terminated = true - instance.TerminatedAt = pointer.For(now.UTC()) + instance.TerminatedAt = pointer.For(now.UTC().Time) err := store.InstancesUpdate(ctx, instance) require.NoError(t, err) @@ -138,7 +138,7 @@ func TestInstancesUpdate(t *testing.T) { instance := defaultWorkflowInstances[2] instance.Error = pointer.For("test error2") instance.Terminated = true - instance.TerminatedAt = pointer.For(now.UTC()) + instance.TerminatedAt = pointer.For(now.UTC().Time) err := store.InstancesUpdate(ctx, instance) require.NoError(t, err)