naise_pos/db/sqlc/main_test.go

32 lines
491 B
Go
Raw Normal View History

2023-03-05 23:35:41 +07:00
package db
import (
"database/sql"
"log"
"os"
"testing"
2023-03-08 15:22:57 +07:00
"git.nochill.in/nochill/naice_pos/util"
2023-03-05 23:35:41 +07:00
_ "github.com/lib/pq"
)
var testQueries *Queries
var testDB *sql.DB
func TestMain(m *testing.M) {
var err error
2023-03-08 15:22:57 +07:00
config, err := util.LoadConfig("../..")
if err != nil {
log.Fatal("cannot load config: ", err)
}
testDB, err = sql.Open(config.DBDriver, config.DBSource)
2023-03-05 23:35:41 +07:00
if err != nil {
log.Fatal("cannot connect to db:", err)
}
testQueries = New(testDB)
os.Exit(m.Run())
}