From 14ca086c720bbf4de3ac9f89f67edc743754096a Mon Sep 17 00:00:00 2001 From: Elle Mouton Date: Mon, 19 May 2025 13:43:09 +0200 Subject: [PATCH] graph/db: skip TestGraphLoading for non-bbolt store Let all the NewTestDB functions return the V1Store interface type instead of pointers. Then add a manual skip in the TestGraphLoading test for any non-bbolt backend. We can remove this once all the methods used by the test have been implemented by the SQLStore. We only need the manual skip for this one test since it is the only one that doesnt use MakeGraphTest to init the graph db. --- graph/db/graph_test.go | 9 +++++++++ graph/db/test_kvdb.go | 2 +- graph/db/test_postgres.go | 2 +- graph/db/test_sqlite.go | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/graph/db/graph_test.go b/graph/db/graph_test.go index 2f2527a14..cab857fee 100644 --- a/graph/db/graph_test.go +++ b/graph/db/graph_test.go @@ -4232,6 +4232,15 @@ func TestGraphLoading(t *testing.T) { // Next, create the graph for the first time. graphStore := NewTestDB(t) + // Temporarily add a manual skip for this test, until all the methods + // it uses have been implemented on the SQLStore struct. We have to + // manually add this skip because it is the only test that doesn't use + // the MakeTestGraph helper to create the graph store. + _, ok := graphStore.(*KVStore) + if !ok { + t.Skipf("Skipping TestGraphLoading for non-bbolt graph store") + } + graph, err := NewChannelGraph(graphStore) require.NoError(t, err) require.NoError(t, graph.Start()) diff --git a/graph/db/test_kvdb.go b/graph/db/test_kvdb.go index 0dd3bd2ff..f325d41f0 100644 --- a/graph/db/test_kvdb.go +++ b/graph/db/test_kvdb.go @@ -10,7 +10,7 @@ import ( ) // NewTestDB is a helper function that creates an BBolt database for testing. -func NewTestDB(t testing.TB) *KVStore { +func NewTestDB(t testing.TB) V1Store { backend, backendCleanup, err := kvdb.GetTestBackend(t.TempDir(), "cgr") require.NoError(t, err) diff --git a/graph/db/test_postgres.go b/graph/db/test_postgres.go index 0c2163083..7509a5907 100644 --- a/graph/db/test_postgres.go +++ b/graph/db/test_postgres.go @@ -14,7 +14,7 @@ import ( // NewTestDB is a helper function that creates a SQLStore backed by a postgres // database for testing. At the moment, it embeds a KVStore but once the // SQLStore fully implements the V1Store interface, the KVStore will be removed. -func NewTestDB(t testing.TB) *SQLStore { +func NewTestDB(t testing.TB) V1Store { backend, backendCleanup, err := kvdb.GetTestBackend(t.TempDir(), "cgr") require.NoError(t, err) diff --git a/graph/db/test_sqlite.go b/graph/db/test_sqlite.go index 5cfe16812..601bba6fb 100644 --- a/graph/db/test_sqlite.go +++ b/graph/db/test_sqlite.go @@ -14,7 +14,7 @@ import ( // NewTestDB is a helper function that creates a SQLStore backed by a sqlite // database for testing. At the moment, it embeds a KVStore but once the // SQLStore fully implements the V1Store interface, the KVStore will be removed. -func NewTestDB(t testing.TB) *SQLStore { +func NewTestDB(t testing.TB) V1Store { backend, backendCleanup, err := kvdb.GetTestBackend(t.TempDir(), "cgr") require.NoError(t, err)