Skip to content

Commit

Permalink
Merge pull request #245 from LerianStudio/refactor/MZ-632
Browse files Browse the repository at this point in the history
Refactor/MZ-632
  • Loading branch information
MartinezAvellan authored Nov 13, 2024
2 parents 7026f3b + 7cf4009 commit 3522bca
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ func (uc *UseCase) CreateAssetRate(ctx context.Context, organizationID, ledgerID
}

assetRateDB := &ar.AssetRate{
ID: uuid.New().String(),
ID: common.GenerateUUIDv7().String(),
BaseAssetCode: cari.BaseAssetCode,
CounterAssetCode: cari.CounterAssetCode,
Amount: cari.Amount,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,21 @@ package command
import (
"context"
"errors"
"github.com/LerianStudio/midaz/common"
"testing"

ar "github.com/LerianStudio/midaz/components/transaction/internal/domain/assetrate"
mock "github.com/LerianStudio/midaz/components/transaction/internal/gen/mock/assetrate"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"go.uber.org/mock/gomock"
)

// TestCreateAssetRateSuccess is responsible to test CreateAssetRate with success
func TestCreateAssetRateSuccess(t *testing.T) {
assetRate := &ar.AssetRate{
ID: uuid.New().String(),
OrganizationID: uuid.New().String(),
LedgerID: uuid.New().String(),
ID: common.GenerateUUIDv7().String(),
OrganizationID: common.GenerateUUIDv7().String(),
LedgerID: common.GenerateUUIDv7().String(),
}

uc := UseCase{
Expand All @@ -39,9 +39,9 @@ func TestCreateAssetRateSuccess(t *testing.T) {
func TestCreateAssetRateError(t *testing.T) {
errMSG := "err to create asset rate on database"
assetRate := &ar.AssetRate{
ID: uuid.New().String(),
OrganizationID: uuid.New().String(),
LedgerID: uuid.New().String(),
ID: common.GenerateUUIDv7().String(),
OrganizationID: common.GenerateUUIDv7().String(),
LedgerID: common.GenerateUUIDv7().String(),
}

uc := UseCase{
Expand Down
5 changes: 2 additions & 3 deletions components/transaction/internal/domain/assetrate/assetrate.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package assetrate

import (
"github.com/LerianStudio/midaz/common"
"time"

"github.com/google/uuid"
)

// AssetRatePostgreSQLModel represents the entity AssetRatePostgreSQLModel into SQL context in Database
Expand Down Expand Up @@ -64,7 +63,7 @@ func (a *AssetRatePostgreSQLModel) ToEntity() *AssetRate {
// FromEntity converts an entity AssetRate to AssetRatePostgreSQLModel
func (a *AssetRatePostgreSQLModel) FromEntity(assetRate *AssetRate) {
*a = AssetRatePostgreSQLModel{
ID: uuid.New().String(),
ID: common.GenerateUUIDv7().String(),
BaseAssetCode: assetRate.BaseAssetCode,
CounterAssetCode: assetRate.CounterAssetCode,
Amount: assetRate.Amount,
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CREATE TABLE IF NOT EXISTS "transaction" (
id UUID PRIMARY KEY NOT NULL DEFAULT (uuid_generate_v4()),
id UUID PRIMARY KEY NOT NULL,
parent_transaction_id UUID,
description TEXT NOT NULL,
template TEXT NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CREATE TABLE IF NOT EXISTS operation (
id UUID PRIMARY KEY NOT NULL DEFAULT (uuid_generate_v4()),
id UUID PRIMARY KEY NOT NULL,
transaction_id UUID NOT NULL,
description TEXT NOT NULL,
type TEXT NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
CREATE TABLE IF NOT EXISTS asset_rate (
id UUID PRIMARY KEY NOT NULL DEFAULT (uuid_generate_v4()),
id UUID PRIMARY KEY NOT NULL,
base_asset_code TEXT NOT NULL,
counter_asset_code TEXT NOT NULL,
amount NUMERIC NOT NULL,
Expand Down

0 comments on commit 3522bca

Please sign in to comment.