session: update NewTestDB funcs to return Store

In preparation for upcoming migration tests from a kvdb to an SQL store,
this commit updates the NewTestDB function to return the Store interface
rather than a concrete store implementation.

This change ensures that migration tests can call NewTestDB under any
build tag while receiving a consistent return type.
This commit is contained in:
Viktor Tigerström 2025-04-30 00:12:39 +07:00
parent d593098cd3
commit b48e40f000
No known key found for this signature in database
GPG key ID: B984570980684DCC
4 changed files with 9 additions and 9 deletions

View file

@ -11,14 +11,14 @@ import (
)
// NewTestDB is a helper function that creates an BBolt database for testing.
func NewTestDB(t *testing.T, clock clock.Clock) *BoltStore {
func NewTestDB(t *testing.T, clock clock.Clock) Store {
return NewTestDBFromPath(t, t.TempDir(), clock)
}
// NewTestDBFromPath is a helper function that creates a new BoltStore with a
// connection to an existing BBolt database for testing.
func NewTestDBFromPath(t *testing.T, dbPath string,
clock clock.Clock) *BoltStore {
clock clock.Clock) Store {
acctStore := accounts.NewTestDB(t, clock)
@ -28,13 +28,13 @@ func NewTestDBFromPath(t *testing.T, dbPath string,
// NewTestDBWithAccounts creates a new test session Store with access to an
// existing accounts DB.
func NewTestDBWithAccounts(t *testing.T, clock clock.Clock,
acctStore accounts.Store) *BoltStore {
acctStore accounts.Store) Store {
return newDBFromPathWithAccounts(t, clock, t.TempDir(), acctStore)
}
func newDBFromPathWithAccounts(t *testing.T, clock clock.Clock, dbPath string,
acctStore accounts.Store) *BoltStore {
acctStore accounts.Store) Store {
store, err := NewDB(dbPath, DBFilename, clock, acctStore)
require.NoError(t, err)

View file

@ -15,14 +15,14 @@ import (
var ErrDBClosed = errors.New("database is closed")
// NewTestDB is a helper function that creates an SQLStore database for testing.
func NewTestDB(t *testing.T, clock clock.Clock) *SQLStore {
func NewTestDB(t *testing.T, clock clock.Clock) Store {
return NewSQLStore(db.NewTestPostgresDB(t).BaseDB, clock)
}
// NewTestDBFromPath is a helper function that creates a new SQLStore with a
// connection to an existing postgres database for testing.
func NewTestDBFromPath(t *testing.T, dbPath string,
clock clock.Clock) *SQLStore {
clock clock.Clock) Store {
return NewSQLStore(db.NewTestPostgresDB(t).BaseDB, clock)
}

View file

@ -11,7 +11,7 @@ import (
)
func NewTestDBWithAccounts(t *testing.T, clock clock.Clock,
acctStore accounts.Store) *SQLStore {
acctStore accounts.Store) Store {
accounts, ok := acctStore.(*accounts.SQLStore)
require.True(t, ok)

View file

@ -15,14 +15,14 @@ import (
var ErrDBClosed = errors.New("database is closed")
// NewTestDB is a helper function that creates an SQLStore database for testing.
func NewTestDB(t *testing.T, clock clock.Clock) *SQLStore {
func NewTestDB(t *testing.T, clock clock.Clock) Store {
return NewSQLStore(db.NewTestSqliteDB(t).BaseDB, clock)
}
// NewTestDBFromPath is a helper function that creates a new SQLStore with a
// connection to an existing sqlite database for testing.
func NewTestDBFromPath(t *testing.T, dbPath string,
clock clock.Clock) *SQLStore {
clock clock.Clock) Store {
return NewSQLStore(
db.NewTestSqliteDbHandleFromPath(t, dbPath).BaseDB, clock,