feat: add native Windows hierarchy test harness
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"net/url"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -116,8 +117,7 @@ func Open(ctx context.Context, options Options) (*Store, error) {
|
||||
query.Add("_pragma", "foreign_keys(ON)")
|
||||
query.Add("_pragma", "synchronous(FULL)")
|
||||
query.Add("_pragma", "busy_timeout("+strconv.FormatInt(options.BusyTimeout.Milliseconds(), 10)+")")
|
||||
databaseURL := &url.URL{Scheme: "file", Path: filepath.ToSlash(databasePath), RawQuery: query.Encode()}
|
||||
db, err := sql.Open("sqlite", databaseURL.String())
|
||||
db, err := sql.Open("sqlite", sqliteFileURI(databasePath, query))
|
||||
if err != nil {
|
||||
_ = unlock()
|
||||
return nil, err
|
||||
@@ -136,6 +136,17 @@ func Open(ctx context.Context, options Options) (*Store, error) {
|
||||
return store, nil
|
||||
}
|
||||
|
||||
// sqliteFileURI creates a file: URI with no authority. SQLite requires a
|
||||
// Windows drive path to be /C:/... in the URI path; without the leading slash
|
||||
// net/url renders C: as an authority (file://C:/...), which SQLite rejects.
|
||||
func sqliteFileURI(path string, query url.Values) string {
|
||||
path = strings.ReplaceAll(path, `\`, "/")
|
||||
if len(path) >= 2 && path[1] == ':' {
|
||||
path = "/" + path
|
||||
}
|
||||
return (&url.URL{Scheme: "file", Path: path, RawQuery: query.Encode()}).String()
|
||||
}
|
||||
|
||||
func (store *Store) ClientInstanceID() domain.UUID { return store.identity }
|
||||
|
||||
func (store *Store) Close() error {
|
||||
|
||||
Reference in New Issue
Block a user