Skip to content

Commit

Permalink
dbname
Browse files Browse the repository at this point in the history
  • Loading branch information
flimzy committed Nov 23, 2023
1 parent 15ec007 commit 6590e3a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ jobs:
go-version: ${{ matrix.go }}
- name: Run integration tests
env:
MYSQL_DSN: "mysql://root:pass@localhost/txdb_test"
PSQL_DSN: "postgres://postgres:pass@localhost/txdb_test"
MYSQL_DSN: "root:pass@/"
PSQL_DSN: "postgres://postgres:pass@localhost/"
run: go test ./...
14 changes: 5 additions & 9 deletions bootstrap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package txdb_test

import (
"database/sql"
"fmt"
"net/url"
"strings"
"testing"
)

Expand All @@ -23,17 +22,14 @@ const (
)`

inserts = `INSERT INTO users (username, email) VALUES ('gopher', 'gopher@go.com'), ('john', 'john@doe.com'), ('jane', 'jane@doe.com')`

testDB = "txdb_test"
)

// bootstrap bootstraps the database with the nfor tests.
func bootstrap(t *testing.T, driver, dsn string) {
parsed, err := url.Parse(dsn)
if err != nil {
t.Fatalf("failed to parse dsn %q: %s", dsn, err)
}
parsed.Path = "" // Remove the database name from the DSN
fmt.Println("bootstrapping", parsed.String())
db, err := sql.Open(driver, parsed.String())
dsn = strings.TrimSuffix(dsn, "/"+testDB)
db, err := sql.Open(driver, dsn)
if err != nil {
t.Fatal(err)
}
Expand Down
1 change: 1 addition & 0 deletions db_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func (d *testDriver) dsn(t *testing.T) string {
if dsn == "" {
t.Skipf("%s not set, skipping tests for %s", d.dsnEnvKey, d.driver)
}
dsn = strings.TrimSuffix(dsn, "/") + "/" + testDB
if d.options == "" {
return dsn
}
Expand Down

0 comments on commit 6590e3a

Please sign in to comment.