Skip to content

Commit

Permalink
Merge pull request #3 from tonybka/feature/tonybka/sample-custom-gorm…
Browse files Browse the repository at this point in the history
…-type-uuidv1

Add test with UUID v1 Id, enable gorm log
  • Loading branch information
tonybka authored Dec 19, 2022
2 parents 4e9f855 + 8a170da commit 14bc526
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 14bc526

Please sign in to comment.