-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_helper_test.go
33 lines (28 loc) · 969 Bytes
/
test_helper_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package dbal
import (
"net/url"
"os"
"testing"
"github.com/stretchr/testify/require"
)
var badSQLStmnt = `SSSSSS`
var insertCustomer = `insert into customers(first_name, last_name, address) values($first_name, $last_name, CAST(NULLIF($address, '') as jsonb));`
var selectCustomer = `select first_name, last_name, address from customers where first_name = $first_name AND last_name = $last_name;`
var selectAllCustomers = `select first_name, last_name, address from customers;`
var deleteCustomer = `delete from customers where first_name = $first_name and last_name = $last_name;`
func testPgDbCreds(t *testing.T) *url.URL {
v := os.Getenv("DBAL_PG_DB")
if v == "" {
v = "postgres://dbal:dbal@localhost:5432/dbal_development?sslmode=disable"
}
u, err := url.Parse(v)
require.NoError(t, err)
return u
}
func testLoadDBAL(t *testing.T) DBAL {
db, err := Open("postgres", testPgDbCreds(t).String())
require.NoError(t, err)
return &dbal{
db: db,
}
}