Files
api_tmpl/internal/db/sqlc/main_test.go
T
2026-01-08 01:15:07 +00:00

31 lines
543 B
Go

package db
import (
"context"
"log"
"os"
"testing"
"github.com/FernandoJVideira/simple_bank/internal/config"
"github.com/jackc/pgx/v5/pgxpool"
_ "github.com/jackc/pgx/v5/stdlib"
)
var testStore Store
func TestMain(m *testing.M) {
config, err := config.LoadTestConfig("../../..")
if err != nil {
log.Fatal("cannot load config:", err)
}
connPool, err := pgxpool.New(context.Background(), config.DBAddr)
if err != nil {
log.Fatal("cannot connect to db:", err)
}
testStore = NewPostgresStore(connPool)
os.Exit(m.Run())
}