Skip to content

Commit

Permalink
General cleanup, maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth Shaw committed Sep 10, 2020
1 parent 1e0bb0a commit 05e5908
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 268 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,6 @@ supported out of the box:
| TiDB (tidb) | ti [mysql] |
| Vitess (vitess) | vt [mysql] |
| | |
| Google Spanner (spanner) | gs, google, span (not yet public) |
| | |
| MySQL (mymysql) | zm, mymy |
| PostgreSQL (pgx) | px |
| | |
Expand Down Expand Up @@ -167,8 +165,6 @@ to be imported:
| TiDB (tidb) | [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) |
| Vitess (vitess) | [github.com/go-sql-driver/mysql](https://github.com/go-sql-driver/mysql) |
| | |
| Google Spanner (spanner) | github.com/xo/spanner (not yet public) |
| | |
| MySQL (mymysql) | [github.com/ziutek/mymysql/godrv](https://github.com/ziutek/mymysql) |
| PostgreSQL (pgx) | [github.com/jackc/pgx/stdlib](https://github.com/jackc/pgx) |
| | |
Expand Down
5 changes: 0 additions & 5 deletions dburl.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,6 @@
// TiDB (tidb) | ti [mysql]
// Vitess (vitess) | vt [mysql]
// -------------------------------|--------------------------------------------
// Google Spanner (spanner) | gs, google, span (not yet public)
// -------------------------------|--------------------------------------------
// MySQL (mymysql) | zm, mymy
// PostgreSQL (pgx) | px
// -------------------------------|--------------------------------------------
Expand Down Expand Up @@ -131,8 +129,6 @@
// TiDB (tidb) | github.com/go-sql-driver/mysql
// Vitess (vitess) | github.com/go-sql-driver/mysql
// -------------------------------|-------------------------------------------------
// Google Spanner (spanner) | github.com/xo/spanner (not yet public)
// -------------------------------|-------------------------------------------------
// MySQL (mymysql) | github.com/ziutek/mymysql/godrv
// PostgreSQL (pgx) | github.com/jackc/pgx/stdlib
// -------------------------------|-------------------------------------------------
Expand Down Expand Up @@ -218,6 +214,5 @@ func Open(urlstr string) (*sql.DB, error) {
if err != nil {
return nil, err
}

return sql.Open(u.Driver, u.DSN)
}
20 changes: 8 additions & 12 deletions dburl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ func TestBadParse(t *testing.T) {
{`mq+unix://`, ErrInvalidTransportProtocol},
{`mq+tcp://`, ErrInvalidTransportProtocol},
}

for i, test := range tests {
_, err := Parse(test.s)
if err == nil {
Expand Down Expand Up @@ -159,27 +158,24 @@ func TestParse(t *testing.T) {

{`ve://user:pass@vertica-host/dbvertica?tlsmode=server-strict`, `vertica`, `vertica://user:pass@vertica-host:5433/dbvertica?tlsmode=server-strict`, ``}, // 68

{`moderncsqlite:///path/to/file.sqlite3`, `sqlite`, `/path/to/file.sqlite3`, ``},
{`modernsqlite:///path/to/file.sqlite3`, `sqlite`, `/path/to/file.sqlite3`, ``},
{`mq://path/to/file.sqlite3`, `sqlite`, `path/to/file.sqlite3`, ``},
{`mq:path/to/file.sqlite3`, `sqlite`, `path/to/file.sqlite3`, ``},
{`mq:./path/to/file.sqlite3`, `sqlite`, `./path/to/file.sqlite3`, ``},
{`mq://./path/to/file.sqlite3?loc=auto`, `sqlite`, `./path/to/file.sqlite3?loc=auto`, ``},
{`mq::memory:?loc=auto`, `sqlite`, `:memory:?loc=auto`, ``},
{`mq://:memory:?loc=auto`, `sqlite`, `:memory:?loc=auto`, ``},
{`moderncsqlite:///path/to/file.sqlite3`, `moderncsqlite`, `/path/to/file.sqlite3`, ``},
{`modernsqlite:///path/to/file.sqlite3`, `moderncsqlite`, `/path/to/file.sqlite3`, ``},
{`mq://path/to/file.sqlite3`, `moderncsqlite`, `path/to/file.sqlite3`, ``},
{`mq:path/to/file.sqlite3`, `moderncsqlite`, `path/to/file.sqlite3`, ``},
{`mq:./path/to/file.sqlite3`, `moderncsqlite`, `./path/to/file.sqlite3`, ``},
{`mq://./path/to/file.sqlite3?loc=auto`, `moderncsqlite`, `./path/to/file.sqlite3?loc=auto`, ``},
{`mq::memory:?loc=auto`, `moderncsqlite`, `:memory:?loc=auto`, ``},
{`mq://:memory:?loc=auto`, `moderncsqlite`, `:memory:?loc=auto`, ``},
}

for i, test := range tests {
u, err := Parse(test.s)
if err != nil {
t.Errorf("test %d expected no error, got: %v", i, err)
continue
}

if u.Driver != test.d {
t.Errorf("test %d expected driver `%s`, got: `%s`", i, test.d, u.Driver)
}

if u.DSN != test.exp {
_, err := os.Stat(test.path)
if test.path != "" && err != nil && os.IsNotExist(err) {
Expand Down
Loading

0 comments on commit 05e5908

Please sign in to comment.