From 92689c546cd8a6674c591dcc394c5fc186ea5396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Viktor=20Tigerstr=C3=B6m?= Date: Thu, 24 Apr 2025 15:48:10 +0700 Subject: [PATCH] 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. --- accounts/test_kvdb.go | 4 ++-- accounts/test_postgres.go | 4 ++-- accounts/test_sqlite.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/accounts/test_kvdb.go b/accounts/test_kvdb.go index 99c3e2ae..546c1eee 100644 --- a/accounts/test_kvdb.go +++ b/accounts/test_kvdb.go @@ -15,14 +15,14 @@ import ( var ErrDBClosed = errors.New("database not open") // 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 { store, err := NewBoltStore(dbPath, DBFilename, clock) require.NoError(t, err) diff --git a/accounts/test_postgres.go b/accounts/test_postgres.go index e4ae89bc..609eeb60 100644 --- a/accounts/test_postgres.go +++ b/accounts/test_postgres.go @@ -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) } diff --git a/accounts/test_sqlite.go b/accounts/test_sqlite.go index 9e6916fb..0dd042a2 100644 --- a/accounts/test_sqlite.go +++ b/accounts/test_sqlite.go @@ -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 SQL 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,