31 lines
453 B
Go
31 lines
453 B
Go
package db
|
|
|
|
import (
|
|
"database/sql"
|
|
"log"
|
|
"os"
|
|
"testing"
|
|
|
|
_ "github.com/lib/pq"
|
|
)
|
|
|
|
const (
|
|
dbDriver = "postgres"
|
|
dbSource = "postgresql://postgres:awksed123@localhost:5432/nice_pos?sslmode=disable"
|
|
)
|
|
|
|
var testQueries *Queries
|
|
var testDB *sql.DB
|
|
|
|
func TestMain(m *testing.M) {
|
|
var err error
|
|
testDB, err = sql.Open(dbDriver, dbSource)
|
|
if err != nil {
|
|
log.Fatal("cannot connect to db:", err)
|
|
}
|
|
|
|
testQueries = New(testDB)
|
|
|
|
os.Exit(m.Run())
|
|
}
|