Skip to content

Commit

Permalink
Merge pull request #910 from go-kivik/keepTestDBs
Browse files Browse the repository at this point in the history
Make it possible to keep test databases
  • Loading branch information
flimzy authored Mar 28, 2024
2 parents 1540c3b + 8903611 commit 2d5f77e
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion x/sqlite/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package sqlite

import (
"context"
"os"
"testing"

"github.com/go-kivik/kivik/v4/driver"
Expand All @@ -25,8 +26,20 @@ import (
// newDB creates a new driver.DB instance backed by an in-memory SQLite database,
// and registers a cleanup function to close the database when the test is done.
func newDB(t *testing.T) driver.DB {
dsn := ":memory:"
if os.Getenv("KEEP_TEST_DB") != "" {
file, err := os.CreateTemp("", "kivik-sqlite-test-*.db")
if err != nil {
t.Fatal(err)
}
dsn = file.Name()
if err := file.Close(); err != nil {
t.Fatal(err)
}
t.Logf("Test database: %s", dsn)
}
d := drv{}
client, err := d.NewClient(":memory:", nil)
client, err := d.NewClient(dsn, nil)
if err != nil {
t.Fatal(err)
}
Expand Down

0 comments on commit 2d5f77e

Please sign in to comment.