Skip to content

Commit

Permalink
Merge branch 'master' into add-with-connection-to-postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasKl committed Feb 21, 2022
2 parents 34c9878 + 0bc9734 commit 3dfae0d
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 233 deletions.
22 changes: 2 additions & 20 deletions database/ql/ql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package ql
import (
"database/sql"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand All @@ -15,15 +13,7 @@ import (
)

func Test(t *testing.T) {
dir, err := ioutil.TempDir("", "ql-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Fatal(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "ql.db"))
p := &Ql{}
addr := fmt.Sprintf("ql://%s", filepath.Join(dir, "ql.db"))
Expand All @@ -45,15 +35,7 @@ func Test(t *testing.T) {
}

func TestMigrate(t *testing.T) {
dir, err := ioutil.TempDir("", "ql-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "ql.db"))

db, err := sql.Open("ql", filepath.Join(dir, "ql.db"))
Expand Down
54 changes: 6 additions & 48 deletions database/sqlcipher/sqlcipher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package sqlcipher
import (
"database/sql"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand All @@ -17,15 +15,7 @@ import (
)

func Test(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite3-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite3.db"))
p := &Sqlite{}
addr := fmt.Sprintf("sqlite3://%s", filepath.Join(dir, "sqlite3.db"))
Expand All @@ -37,15 +27,7 @@ func Test(t *testing.T) {
}

func TestMigrate(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite3-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite3.db"))

db, err := sql.Open("sqlite3", filepath.Join(dir, "sqlite3.db"))
Expand All @@ -72,15 +54,7 @@ func TestMigrate(t *testing.T) {
}

func TestMigrationTable(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite3-driver-test-migration-table")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()

t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite3.db"))

Expand Down Expand Up @@ -120,15 +94,7 @@ func TestMigrationTable(t *testing.T) {
}

func TestNoTxWrap(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite3-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite3.db"))
p := &Sqlite{}
addr := fmt.Sprintf("sqlite3://%s?x-no-tx-wrap=true", filepath.Join(dir, "sqlite3.db"))
Expand All @@ -142,19 +108,11 @@ func TestNoTxWrap(t *testing.T) {
}

func TestNoTxWrapInvalidValue(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite3-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite3.db"))
p := &Sqlite{}
addr := fmt.Sprintf("sqlite3://%s?x-no-tx-wrap=yeppers", filepath.Join(dir, "sqlite3.db"))
_, err = p.Open(addr)
_, err := p.Open(addr)
if assert.Error(t, err) {
assert.Contains(t, err.Error(), "x-no-tx-wrap")
assert.Contains(t, err.Error(), "invalid syntax")
Expand Down
64 changes: 7 additions & 57 deletions database/sqlite/sqlite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package sqlite
import (
"database/sql"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand All @@ -17,15 +15,7 @@ import (
)

func Test(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite.db"))
p := &Sqlite{}
addr := fmt.Sprintf("sqlite://%s", filepath.Join(dir, "sqlite.db"))
Expand All @@ -37,15 +27,7 @@ func Test(t *testing.T) {
}

func TestMigrate(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite.db"))

db, err := sql.Open("sqlite", filepath.Join(dir, "sqlite.db"))
Expand All @@ -72,15 +54,7 @@ func TestMigrate(t *testing.T) {
}

func TestMigrationTable(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite-driver-test-migration-table")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()

t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite.db"))

Expand Down Expand Up @@ -120,15 +94,7 @@ func TestMigrationTable(t *testing.T) {
}

func TestNoTxWrap(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite.db"))
p := &Sqlite{}
addr := fmt.Sprintf("sqlite://%s?x-no-tx-wrap=true", filepath.Join(dir, "sqlite.db"))
Expand All @@ -142,35 +108,19 @@ func TestNoTxWrap(t *testing.T) {
}

func TestNoTxWrapInvalidValue(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite.db"))
p := &Sqlite{}
addr := fmt.Sprintf("sqlite://%s?x-no-tx-wrap=yeppers", filepath.Join(dir, "sqlite.db"))
_, err = p.Open(addr)
_, err := p.Open(addr)
if assert.Error(t, err) {
assert.Contains(t, err.Error(), "x-no-tx-wrap")
assert.Contains(t, err.Error(), "invalid syntax")
}
}

func TestMigrateWithDirectoryNameContainsWhitespaces(t *testing.T) {
dir, err := ioutil.TempDir("", "directory name contains whitespaces")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
dbPath := filepath.Join(dir, "sqlite.db")
t.Logf("DB path : %s\n", dbPath)
p := &Sqlite{}
Expand Down
64 changes: 7 additions & 57 deletions database/sqlite3/sqlite3_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ package sqlite3
import (
"database/sql"
"fmt"
"io/ioutil"
"os"
"path/filepath"
"testing"

Expand All @@ -17,15 +15,7 @@ import (
)

func Test(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite3-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite3.db"))
p := &Sqlite{}
addr := fmt.Sprintf("sqlite3://%s", filepath.Join(dir, "sqlite3.db"))
Expand All @@ -37,15 +27,7 @@ func Test(t *testing.T) {
}

func TestMigrate(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite3-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite3.db"))

db, err := sql.Open("sqlite3", filepath.Join(dir, "sqlite3.db"))
Expand All @@ -72,15 +54,7 @@ func TestMigrate(t *testing.T) {
}

func TestMigrationTable(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite3-driver-test-migration-table")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()

t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite3.db"))

Expand Down Expand Up @@ -120,15 +94,7 @@ func TestMigrationTable(t *testing.T) {
}

func TestNoTxWrap(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite3-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite3.db"))
p := &Sqlite{}
addr := fmt.Sprintf("sqlite3://%s?x-no-tx-wrap=true", filepath.Join(dir, "sqlite3.db"))
Expand All @@ -142,35 +108,19 @@ func TestNoTxWrap(t *testing.T) {
}

func TestNoTxWrapInvalidValue(t *testing.T) {
dir, err := ioutil.TempDir("", "sqlite3-driver-test")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
t.Logf("DB path : %s\n", filepath.Join(dir, "sqlite3.db"))
p := &Sqlite{}
addr := fmt.Sprintf("sqlite3://%s?x-no-tx-wrap=yeppers", filepath.Join(dir, "sqlite3.db"))
_, err = p.Open(addr)
_, err := p.Open(addr)
if assert.Error(t, err) {
assert.Contains(t, err.Error(), "x-no-tx-wrap")
assert.Contains(t, err.Error(), "invalid syntax")
}
}

func TestMigrateWithDirectoryNameContainsWhitespaces(t *testing.T) {
dir, err := ioutil.TempDir("", "directory name contains whitespaces")
if err != nil {
return
}
defer func() {
if err := os.RemoveAll(dir); err != nil {
t.Error(err)
}
}()
dir := t.TempDir()
dbPath := filepath.Join(dir, "sqlite3.db")
t.Logf("DB path : %s\n", dbPath)
p := &Sqlite{}
Expand Down
Loading

0 comments on commit 3dfae0d

Please sign in to comment.