Fix tests

This commit is contained in:
Jinzhu 2021-11-29 15:16:57 +08:00
parent 270e38c518
commit 92d5a959a0
3 changed files with 3 additions and 4 deletions

View File

@ -4,8 +4,7 @@ go 1.14
require ( require (
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0
github.com/jackc/pgtype v1.9.1 // indirect github.com/jackc/pgx/v4 v4.14.1 // indirect
github.com/jackc/pgx/v4 v4.14.0 // indirect
github.com/jinzhu/now v1.1.3 github.com/jinzhu/now v1.1.3
github.com/lib/pq v1.10.4 github.com/lib/pq v1.10.4
golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect golang.org/x/crypto v0.0.0-20211117183948-ae814b36b871 // indirect

View File

@ -11,7 +11,7 @@ import (
) )
func TestMigrate(t *testing.T) { func TestMigrate(t *testing.T) {
allModels := []interface{}{&User{}, &Account{}, &Pet{}, &Company{}, &Toy{}, &Language{}, &Coupon{}, &CouponProduct{}} allModels := []interface{}{&User{}, &Account{}, &Pet{}, &Company{}, &Toy{}, &Language{}}
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
rand.Shuffle(len(allModels), func(i, j int) { allModels[i], allModels[j] = allModels[j], allModels[i] }) rand.Shuffle(len(allModels), func(i, j int) { allModels[i], allModels[j] = allModels[j], allModels[i] })
DB.Migrator().DropTable("user_speaks", "user_friends", "ccc") DB.Migrator().DropTable("user_speaks", "user_friends", "ccc")

View File

@ -87,7 +87,7 @@ func OpenTestConnection() (db *gorm.DB, err error) {
func RunMigrations() { func RunMigrations() {
var err error var err error
allModels := []interface{}{&User{}, &Account{}, &Pet{}, &Company{}, &Toy{}, &Language{}} allModels := []interface{}{&User{}, &Account{}, &Pet{}, &Company{}, &Toy{}, &Language{}, &Coupon{}, &CouponProduct{}}
rand.Seed(time.Now().UnixNano()) rand.Seed(time.Now().UnixNano())
rand.Shuffle(len(allModels), func(i, j int) { allModels[i], allModels[j] = allModels[j], allModels[i] }) rand.Shuffle(len(allModels), func(i, j int) { allModels[i], allModels[j] = allModels[j], allModels[i] })