Support uuids

This commit is contained in:
Eden Kirin
2024-06-24 16:18:10 +02:00
parent bd510d958b
commit 9958e9103b
3 changed files with 82 additions and 30 deletions

View File

@ -8,6 +8,7 @@ import (
"testing"
"github.com/DATA-DOG/go-sqlmock"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"gorm.io/driver/postgres"
"gorm.io/gorm"
@ -32,7 +33,7 @@ func NewMockDB() (*sql.DB, *gorm.DB, sqlmock.Sqlmock) {
}
type MyModel struct {
Id int
Id uuid.UUID
Value string
Count int
}
@ -42,9 +43,9 @@ func (m MyModel) TableName() string {
}
type MyModelFilter struct {
Id *int `filterfield:"field=id,operator=EQ"`
Value *string `filterfield:"field=value,operator=EQ"`
Count *int `filterfield:"field=count,operator=GT"`
Id *uuid.UUID `filterfield:"field=id,operator=EQ"`
Value *string `filterfield:"field=value,operator=EQ"`
Count *int `filterfield:"field=count,operator=GT"`
}
func TestListMethod(t *testing.T) {
@ -166,7 +167,7 @@ func TestListMethod(t *testing.T) {
repo := RepoBase[MyModel]{}
repo.Init(db)
id := 123
id := uuid.New()
filter := MyModelFilter{
Id: &id,
}
@ -190,7 +191,7 @@ func TestListMethod(t *testing.T) {
repo := RepoBase[MyModel]{}
repo.Init(db)
id := 123
id := uuid.New()
count := 456
value := "some value"
filter := MyModelFilter{
@ -218,7 +219,7 @@ func TestListMethod(t *testing.T) {
repo := RepoBase[MyModel]{}
repo.Init(db)
id := 123
id := uuid.New()
count := 456
value := "some value"
filter := MyModelFilter{