nginx-proxy-manager-zh/backend/internal/test/suite.go

24 lines
428 B
Go
Raw Normal View History

2023-07-25 23:29:12 -04:00
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
}