Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test workflow #27

Merged
merged 3 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Test
on: [pull_request]

concurrency:
group: test-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
test:
strategy:
fail-fast: false
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
id: go
- name: Test
run: go test ./...
- name: Test Race
run: go test -race ./...
11 changes: 10 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,11 @@ 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, `\`, `/`)
}
return dir
}
Loading