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 }