hiling_go/db/sqlc/test/main_test.go
2024-02-06 11:55:25 +07:00

33 lines
575 B
Go

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())
}