Skip to content

Commit a7ecf0a

Browse files
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.
1 parent 3c42778 commit a7ecf0a

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

session/test_kvdb.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ import (
1111
)
1212

1313
// NewTestDB is a helper function that creates an BBolt database for testing.
14-
func NewTestDB(t *testing.T, clock clock.Clock) *BoltStore {
14+
func NewTestDB(t *testing.T, clock clock.Clock) Store {
1515
return NewTestDBFromPath(t, t.TempDir(), clock)
1616
}
1717

1818
// NewTestDBFromPath is a helper function that creates a new BoltStore with a
1919
// connection to an existing BBolt database for testing.
2020
func NewTestDBFromPath(t *testing.T, dbPath string,
21-
clock clock.Clock) *BoltStore {
21+
clock clock.Clock) Store {
2222

2323
acctStore := accounts.NewTestDB(t, clock)
2424

@@ -28,13 +28,13 @@ func NewTestDBFromPath(t *testing.T, dbPath string,
2828
// NewTestDBWithAccounts creates a new test session Store with access to an
2929
// existing accounts DB.
3030
func NewTestDBWithAccounts(t *testing.T, clock clock.Clock,
31-
acctStore accounts.Store) *BoltStore {
31+
acctStore accounts.Store) Store {
3232

3333
return newDBFromPathWithAccounts(t, clock, t.TempDir(), acctStore)
3434
}
3535

3636
func newDBFromPathWithAccounts(t *testing.T, clock clock.Clock, dbPath string,
37-
acctStore accounts.Store) *BoltStore {
37+
acctStore accounts.Store) Store {
3838

3939
store, err := NewDB(dbPath, DBFilename, clock, acctStore)
4040
require.NoError(t, err)

session/test_postgres.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import (
1515
var ErrDBClosed = errors.New("database is closed")
1616

1717
// NewTestDB is a helper function that creates an SQLStore database for testing.
18-
func NewTestDB(t *testing.T, clock clock.Clock) *SQLStore {
18+
func NewTestDB(t *testing.T, clock clock.Clock) Store {
1919
return NewSQLStore(db.NewTestPostgresDB(t).BaseDB, clock)
2020
}
2121

2222
// NewTestDBFromPath is a helper function that creates a new SQLStore with a
2323
// connection to an existing postgres database for testing.
2424
func NewTestDBFromPath(t *testing.T, dbPath string,
25-
clock clock.Clock) *SQLStore {
25+
clock clock.Clock) Store {
2626

2727
return NewSQLStore(db.NewTestPostgresDB(t).BaseDB, clock)
2828
}

session/test_sql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
func NewTestDBWithAccounts(t *testing.T, clock clock.Clock,
14-
acctStore accounts.Store) *SQLStore {
14+
acctStore accounts.Store) Store {
1515

1616
accounts, ok := acctStore.(*accounts.SQLStore)
1717
require.True(t, ok)

session/test_sqlite.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import (
1515
var ErrDBClosed = errors.New("database is closed")
1616

1717
// NewTestDB is a helper function that creates an SQLStore database for testing.
18-
func NewTestDB(t *testing.T, clock clock.Clock) *SQLStore {
18+
func NewTestDB(t *testing.T, clock clock.Clock) Store {
1919
return NewSQLStore(db.NewTestSqliteDB(t).BaseDB, clock)
2020
}
2121

2222
// NewTestDBFromPath is a helper function that creates a new SQLStore with a
2323
// connection to an existing sqlite database for testing.
2424
func NewTestDBFromPath(t *testing.T, dbPath string,
25-
clock clock.Clock) *SQLStore {
25+
clock clock.Clock) Store {
2626

2727
return NewSQLStore(
2828
db.NewTestSqliteDbHandleFromPath(t, dbPath).BaseDB, clock,

0 commit comments

Comments
 (0)