33 lines
575 B
Go
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())
|
|
}
|