31 lines
543 B
Go
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())
|
|
}
|