hiling_go/db/sqlc/test/main_test.go
2024-05-22 11:26:15 +07:00

33 lines
575 B
Go
Executable File

package db_test
import (
"context"
"log"
"os"
"testing"
db "git.nochill.in/nochill/hiling_go/db/sqlc"
"git.nochill.in/nochill/hiling_go/util"
"github.com/jackc/pgx/v5/pgxpool"
)
var testQueries *db.Queries
var testDB *pgxpool.Pool
func TestMain(m *testing.M) {
var err error
config, err := util.LoadConfig("../../..")
if err != nil {
log.Fatal("cannot load config: ", err)
}
testDB, err = pgxpool.New(context.Background(), config.DBSourceTest)
if err != nil {
log.Fatal("cannot connect db: ", err)
}
testQueries = db.New(testDB)
os.Exit(m.Run())
}