Skip to content

Commit

Permalink
update tests for integration with drone.io
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoiron committed May 29, 2013
1 parent c07b8b6 commit 5d307c5
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions sqlx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
_ "github.com/lib/pq"
_ "github.com/mattn/go-sqlite3"
"os"
"os/user"
"strings"
"testing"
Expand All @@ -30,25 +31,34 @@ func PostgresConnect() {
TestPostgres = false
}
}()
u, err := user.Current()
if err != nil {
fmt.Printf("Could not find current user username, trying 'test' instead.")
username = "test"
} else {
username = u.Username
username = os.Getenv("SQLX_PGUSER")
if len(username) == 0 {
u, err := user.Current()
if err != nil {
fmt.Printf("Could not find current user username, trying 'test' instead.")
username = "test"
} else {
username = u.Username
}

}
pgdb = MustConnect("postgres", "user="+username+" dbname=sqlxtest sslmode=disable")
}

func SqliteConnect() {
var path string
defer func() {
if r := recover(); r != nil {
fmt.Printf("Could not create sqlite3 db in /tmp/sqlxtest.db:\n %v", r)
fmt.Printf("Could not create sqlite3 db in %s:\n %v", path, r)
TestSqlite = false
}
}()

sldb = MustConnect("sqlite3", "/tmp/sqlxtest.db")
path = os.Getenv("SQLX_SQLITE_PATH")
if len(path) == 0 {
path = "/tmp/sqlxtest.db"
}
sldb = MustConnect("sqlite3", path)
}

var schema = `
Expand Down

0 comments on commit 5d307c5

Please sign in to comment.