32 lines
491 B
Go
32 lines
491 B
Go
package db
|
|
|
|
import (
|
|
"database/sql"
|
|
"log"
|
|
"os"
|
|
"testing"
|
|
|
|
"git.nochill.in/nochill/naice_pos/util"
|
|
_ "github.com/lib/pq"
|
|
)
|
|
|
|
var testQueries *Queries
|
|
var testDB *sql.DB
|
|
|
|
func TestMain(m *testing.M) {
|
|
var err error
|
|
config, err := util.LoadConfig("../..")
|
|
if err != nil {
|
|
log.Fatal("cannot load config: ", err)
|
|
}
|
|
|
|
testDB, err = sql.Open(config.DBDriver, config.DBSource)
|
|
if err != nil {
|
|
log.Fatal("cannot connect to db:", err)
|
|
}
|
|
|
|
testQueries = New(testDB)
|
|
|
|
os.Exit(m.Run())
|
|
}
|