10
// Ensures that creating a new SQL Mapper does not encounter an error upon initialization
11
// And also matches the expected database connections and sql configurations.
12
func TestNewSQLMapper(t *testing.T) {
13
conf := sqlConfFromEnv()
14
db, _ := sql.Open(conf.driver, conf.openStr)
16
env := os.Getenv("DB")
17
filepath := fmt.Sprintf("db/%s/dbconf.yml", env)
18
s, _ := NewSQLMapper(filepath, db)
21
t.Error("Expected NewSqlMapper to return a non-nil pointer to a sql mapper")
29
// Ensures that creating a new SQLMapper and getting its SQL DB Connection
30
// is the same *sql.DB used in initialization.
31
func TestSqlDbConn(t *testing.T) {
32
conf := sqlConfFromEnv()
33
db, _ := sql.Open(conf.driver, conf.openStr)
35
env := os.Getenv("DB")
36
filepath := fmt.Sprintf("db/%s/dbconf.yml", env)
37
s, _ := NewSQLMapper(filepath, db)
39
if s.SqlDbConn() != db {
40
t.Error("Expected db connections are mismatched.")