Skip to content

Commit

Permalink
Bug fix for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmu committed Jun 10, 2024
1 parent 35a04c4 commit eb4eaf8
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion smoke_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"database/sql"
"net/url"
"os"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -195,7 +196,7 @@ func initializeTestDatabaseConnection(t *testing.T, clientFoundRows bool) (conn
if clientFoundRows {
query["clientfoundrows"] = []string{"true"}
}
dsn := url.URL{Scheme: "file", Path: dir, RawQuery: query.Encode()}
dsn := url.URL{Scheme: "file", Path: encodeDir(dir), RawQuery: query.Encode()}
db, err := sql.Open(DoltDriverName, dsn.String())
require.NoError(t, err)
require.NoError(t, db.PingContext(ctx))
Expand All @@ -210,3 +211,13 @@ func initializeTestDatabaseConnection(t *testing.T, clientFoundRows bool) (conn

return conn, cleanUpFunc
}

func encodeDir(dir string) string {
// encodeDir translate a given path to a URL compatible path, mostly for windows compatibility
if os.PathSeparator == '\\' {
dir = strings.ReplaceAll(dir, `\`, `/`)
// strip off drive letter
dir = dir[2:]
}
return dir
}

0 comments on commit eb4eaf8

Please sign in to comment.