Skip to content

Commit 76361cf

Browse files
Fixing TestScannerValuer and TestInvalidValuer
1 parent 3a7e805 commit 76361cf

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

tests/scanner_valuer_test.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ import (
5959
)
6060

6161
func TestScannerValuer(t *testing.T) {
62-
t.Skip()
6362
DB.Migrator().DropTable(&ScannerValuerStruct{})
6463
if err := DB.Migrator().AutoMigrate(&ScannerValuerStruct{}); err != nil {
6564
t.Fatalf("no error should happen when migrate scanner, valuer struct, got error %v", err)
@@ -92,7 +91,7 @@ func TestScannerValuer(t *testing.T) {
9291

9392
var result ScannerValuerStruct
9493

95-
if err := DB.Find(&result, "id = ?", data.ID).Error; err != nil {
94+
if err := DB.Find(&result, "\"id\" = ?", data.ID).Error; err != nil {
9695
t.Fatalf("no error should happen when query scanner, valuer struct, but got %v", err)
9796
}
9897

@@ -151,7 +150,6 @@ func TestScannerValuerWithFirstOrCreate(t *testing.T) {
151150
}
152151

153152
func TestInvalidValuer(t *testing.T) {
154-
t.Skip()
155153
DB.Migrator().DropTable(&ScannerValuerStruct{})
156154
if err := DB.Migrator().AutoMigrate(&ScannerValuerStruct{}); err != nil {
157155
t.Errorf("no error should happen when migrate scanner, valuer struct")
@@ -205,6 +203,24 @@ type ScannerValuerStruct struct {
205203
ExampleStructPtr *ExampleStruct
206204
}
207205

206+
func (StringsSlice) GormDataType() string { return "CLOB" }
207+
func (l StringsSlice) GormValue(ctx context.Context, db *gorm.DB) clause.Expr {
208+
v, err := l.Value()
209+
if err != nil {
210+
return gorm.Expr("?", err)
211+
}
212+
return gorm.Expr("?", v)
213+
}
214+
215+
func (StructsSlice) GormDataType() string { return "CLOB" }
216+
func (l StructsSlice) GormValue(ctx context.Context, db *gorm.DB) clause.Expr {
217+
v, err := l.Value()
218+
if err != nil {
219+
return gorm.Expr("?", err)
220+
}
221+
return gorm.Expr("?", v)
222+
}
223+
208224
type EncryptedData []byte
209225

210226
func (data *EncryptedData) Scan(value interface{}) error {

0 commit comments

Comments
 (0)