Skip to content

Commit

Permalink
Fix migration test
Browse files Browse the repository at this point in the history
  • Loading branch information
marco6 committed Jun 27, 2024
1 parent 36366fd commit 1a6ef12
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions pkg/kine/drivers/sqlite/sqlite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,29 @@ package sqlite_test
import (
"context"
"database/sql"
"os"
"path"
"testing"

"github.com/canonical/k8s-dqlite/pkg/kine/drivers/sqlite"
"github.com/sirupsen/logrus"
)

func setupV0(db *sql.DB) error {
func init() {
logrus.SetLevel(logrus.ErrorLevel)
}

func setupV0(db *sql.DB) error {
// Create the very old key_value table
if _, err := db.Exec(`
CREATE TABLE IF NOT EXISTS kine
(
id INTEGER primary key autoincrement,
name INTEGER,
(c
id INTEGER PRIMARY KEY AUTOINCREMENT,
name TEXT NOT NULL,
created INTEGER,
deleted INTEGER,
create_revision INTEGER NOT NULL,
prev_revision INTEGER,
ttl INTEGER,
lease INTEGER,
value BLOB,
old_value BLOB
)`); err != nil {
Expand All @@ -34,18 +38,13 @@ CREATE TABLE IF NOT EXISTS kine
func TestMigration(t *testing.T) {
const driver = "sqlite3"

folder, err := os.MkdirTemp("", "kine_test-")
if err != nil {
t.Fatal(err)
}
defer os.RemoveAll(folder)

folder := t.TempDir()
dbPath := path.Join(folder, "db.sqlite")
db, err := sql.Open(driver, dbPath)
defer db.Close()
if err != nil {
t.Fatal(err)
}
defer db.Close()

setupV0(db)

Expand Down

0 comments on commit 1a6ef12

Please sign in to comment.