Skip to content

Commit 07d69ee

Browse files
accounts: update NewTestDB func 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 c10d981 commit 07d69ee

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

accounts/test_kvdb.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ import (
1515
var ErrDBClosed = errors.New("database not open")
1616

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

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

2727
store, err := NewBoltStore(dbPath, DBFilename, clock)
2828
require.NoError(t, err)

accounts/test_postgres.go

+2-2
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
}

accounts/test_sqlite.go

+2-2
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 SQL 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)