11// The following environment variables, if set, will be used:
22//
3- // * SQLX_SQLITE_DSN
4- // * SQLX_POSTGRES_DSN
5- // * SQLX_MYSQL_DSN
3+ // - SQLX_SQLITE_DSN
4+ // - SQLX_POSTGRES_DSN
5+ // - SQLX_MYSQL_DSN
66//
77// Set any of these variables to 'skip' to skip them. Note that for MySQL,
88// the string '?parseTime=True' will be appended to the DSN if it's not there
99// already.
10- //
1110package sqlx
1211
1312import (
@@ -23,7 +22,7 @@ import (
2322 "time"
2423
2524 _ "github.com/go-sql-driver/mysql"
26- "github.com/jmoiron /sqlx/reflectx"
25+ "github.com/go-sqlx /sqlx/reflectx"
2726 _ "github.com/lib/pq"
2827 _ "github.com/mattn/go-sqlite3"
2928)
@@ -62,34 +61,37 @@ func ConnectAll() {
6261 mydsn += "?parseTime=true"
6362 }
6463
64+ var didRunTests bool = false
6565 if TestPostgres {
6666 pgdb , err = Connect ("postgres" , pgdsn )
6767 if err != nil {
6868 fmt .Printf ("Disabling PG tests:\n %v\n " , err )
6969 TestPostgres = false
70+ } else {
71+ didRunTests = true
7072 }
71- } else {
72- fmt .Println ("Disabling Postgres tests." )
7373 }
74-
7574 if TestMysql {
7675 mysqldb , err = Connect ("mysql" , mydsn )
7776 if err != nil {
78- fmt .Printf ("Disabling MySQL tests:\n %v" , err )
77+ fmt .Printf ("Disabling MySQL tests:\n %v\n " , err )
7978 TestMysql = false
79+ } else {
80+ didRunTests = true
8081 }
81- } else {
82- fmt .Println ("Disabling MySQL tests." )
8382 }
84-
8583 if TestSqlite {
8684 sldb , err = Connect ("sqlite3" , sqdsn )
8785 if err != nil {
88- fmt .Printf ("Disabling SQLite:\n %v" , err )
86+ fmt .Printf ("Disabling SQLite:\n %v\n " , err )
8987 TestSqlite = false
88+ } else {
89+ didRunTests = true
9090 }
91- } else {
92- fmt .Println ("Disabling SQLite tests." )
91+ }
92+
93+ if didRunTests == false {
94+ panic ("No Database connected to" )
9395 }
9496}
9597
0 commit comments