Skip to content

Commit

Permalink
Add test with UUID v1 Id, enable gorm log
Browse files Browse the repository at this point in the history
  • Loading branch information
tonybka committed Dec 19, 2022
1 parent 890f35f commit 8a170da
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions infrastructure/tests/sqlite_db_connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"gorm.io/driver/sqlite"
"gorm.io/gorm"
"gorm.io/gorm/logger"
)

type SqliteDBConnect struct {
Expand All @@ -29,6 +30,7 @@ func NewSqliteDBConnect() (*SqliteDBConnect, error) {

dbConn, err := gorm.Open(dialector, &gorm.Config{
SkipDefaultTransaction: true,
Logger: logger.Default.LogMode(logger.Info),
})
if err != nil {
return nil, err
Expand Down
7 changes: 4 additions & 3 deletions samples/persistence/account/account_repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@ func (ts *AccountRepositoryTestSuite) SetupSuite() {
}

func (ts *AccountRepositoryTestSuite) TestCreateAccount() {
entityId := customgorm.CustomTypeUUIDv1FromString(uuid.New().String())
entityId, err := uuid.NewUUID()
ts.NoError(err)

account := AccountModel{
BaseModel: persistence.BaseModel{
ID: entityId,
ID: customgorm.CustomTypeUUIDv1FromString(entityId.String()),
},
AccountName: "abc",
}

err := ts.accountRepo.Create(account)
err = ts.accountRepo.Create(account)
ts.NoError(err)

all, err := ts.accountRepo.GetAll()
Expand Down

0 comments on commit 8a170da

Please sign in to comment.