nginx-proxy-manager-zh/backend/internal/test/suite.go
2023-07-26 13:29:12 +10:00

24 lines
428 B
Go

package test
import (
"npm/internal/database"
"github.com/DATA-DOG/go-sqlmock"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
func Setup() (sqlmock.Sqlmock, error) {
db, mock, err := sqlmock.New()
if err != nil {
return nil, err
}
dialector := postgres.New(postgres.Config{
Conn: db,
DriverName: "postgres",
})
gormDB, err := gorm.Open(dialector, &gorm.Config{})
database.SetDB(gormDB)
return mock, err
}