Files
docker-agent/pkg/session/sqlite_test_helper_test.go
T
David Gageot a5637e9619 refactor(session)!: move file-backed SQLite store to session/sqlitestore
pkg/session mixed the in-memory store with the file-backed constructor,
so every embedder of pkg/runtime linked modernc.org/sqlite (large and
slow to compile) even when using purely in-memory sessions.

session.NewSQLiteSessionStore(ctx, path) becomes sqlitestore.New(ctx,
path); behavior (open, migrate, backup+retry recovery) is unchanged.
SQLiteSessionStore, NewSQLiteSessionStoreFromDB and the migrations stay
in pkg/session - they only use database/sql and don't drag the driver.

BREAKING CHANGE: callers of session.NewSQLiteSessionStore must import
github.com/docker/docker-agent/pkg/session/sqlitestore and call New.
2026-07-21 15:02:51 +02:00

30 lines
746 B
Go

package session
import (
"testing"
"github.com/stretchr/testify/require"
"github.com/docker/docker-agent/pkg/sqliteutil"
)
// newSQLiteStoreForTest opens a file-backed SQLite store the same way
// sqlitestore.New does on its happy path. In-package tests cannot import
// pkg/session/sqlitestore without an import cycle, and none of them exercise
// its backup/recovery logic (that is tested in sqlitestore itself).
func newSQLiteStoreForTest(t *testing.T, path string) (Store, error) {
t.Helper()
db, err := sqliteutil.OpenDB(t.Context(), path)
if err != nil {
return nil, err
}
store, err := NewSQLiteSessionStoreFromDB(t.Context(), db)
if err != nil {
require.NoError(t, db.Close())
return nil, err
}
return store, nil
}