From 294255c11b1d96abdf3c1f645fc38e489c841dbf Mon Sep 17 00:00:00 2001 From: demoManito <1430482733@qq.com> Date: Fri, 20 Oct 2023 20:44:12 +0800 Subject: [PATCH] fix test --- tests/embedded_struct_test.go | 4 +++- tests/upsert_test.go | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/embedded_struct_test.go b/tests/embedded_struct_test.go index 4314f88c..69031b89 100644 --- a/tests/embedded_struct_test.go +++ b/tests/embedded_struct_test.go @@ -241,7 +241,9 @@ func TestEmbeddedRelations(t *testing.T) { Advanced bool } - DB.Migrator().DropTable(&AdvancedUser{}) + if err := DB.Migrator().DropTable(&AdvancedUser{}); err != nil { + t.Fatal(err) + } if err := DB.AutoMigrate(&AdvancedUser{}); err != nil { if DB.Dialector.Name() != "sqlite" { diff --git a/tests/upsert_test.go b/tests/upsert_test.go index 389d013a..e656e722 100644 --- a/tests/upsert_test.go +++ b/tests/upsert_test.go @@ -62,7 +62,7 @@ func TestUpsert(t *testing.T) { } r := DB.Session(&gorm.Session{DryRun: true}).Clauses(clause.OnConflict{UpdateAll: true}).Create(&RestrictedLanguage{Code: "upsert_code", Name: "upsert_name", Lang: "upsert_lang"}) - if !regexp.MustCompile(`INTO .restricted_languages. .*\(.code.,.name.,.lang.\) .* (SET|UPDATE) .name. = .*.name.\W*$`).MatchString(r.Statement.SQL.String()) { + if !regexp.MustCompile(`INTO .restricted_languages. .*\(.code.,.name.,.lang.\) .* (SET|UPDATE) .name.*=.*.name.\W*$`).MatchString(r.Statement.SQL.String()) { t.Errorf("Table with escape character, got %v", r.Statement.SQL.String()) } }