mirror of
https://github.com/xiaoxinpro/nginx-proxy-manager-zh.git
synced 2025-01-23 21:28:15 -05:00
24 lines
428 B
Go
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
|
|
}
|