common/pkg/database/database_test.go

25 lines
471 B
Go

package database
import (
"fmt"
"gorm.io/driver/postgres"
"gorm.io/gorm"
"testing"
)
type User struct {
ID uint `gorm:"primary_key"`
Name string
Version string
}
func TestMri(t *testing.T) {
dsn := fmt.Sprintf("host=192.168.31.55 user=timerzz password=zhhg1997 dbname=kedaya port=5432 sslmode=disable TimeZone=Asia/Shanghai")
db, _ := gorm.Open(postgres.Open(dsn), &gorm.Config{})
err := db.AutoMigrate(&User{})
if err != nil {
t.Fatal(err)
}
}