From d3488ae6bcee8ccbb1e463a42a048e1958c4c90f Mon Sep 17 00:00:00 2001 From: Heliner <32272517+Heliner@users.noreply.github.com> Date: Sat, 30 Apr 2022 09:50:53 +0800 Subject: [PATCH] fix: add judge result of auto_migrate (#5306) Co-authored-by: fredhan --- tests/migrate_test.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tests/migrate_test.go b/tests/migrate_test.go index 6576a2bd..28ee28cb 100644 --- a/tests/migrate_test.go +++ b/tests/migrate_test.go @@ -639,9 +639,19 @@ func TestMigrateSerialColumn(t *testing.T) { // https://github.com/go-gorm/gorm/issues/5300 func TestMigrateWithSpecialName(t *testing.T) { - DB.AutoMigrate(&Coupon{}) - DB.Table("coupon_product_1").AutoMigrate(&CouponProduct{}) - DB.Table("coupon_product_2").AutoMigrate(&CouponProduct{}) + var err error + err = DB.AutoMigrate(&Coupon{}) + if err != nil { + t.Fatalf("AutoMigrate err:%v", err) + } + err = DB.Table("coupon_product_1").AutoMigrate(&CouponProduct{}) + if err != nil { + t.Fatalf("AutoMigrate err:%v", err) + } + err = DB.Table("coupon_product_2").AutoMigrate(&CouponProduct{}) + if err != nil { + t.Fatalf("AutoMigrate err:%v", err) + } AssertEqual(t, true, DB.Migrator().HasTable("coupons")) AssertEqual(t, true, DB.Migrator().HasTable("coupon_product_1"))