From ca4d44dfd8588ad51d65eeeb6870c43775975e67 Mon Sep 17 00:00:00 2001 From: Jim Date: Fri, 6 Sep 2024 10:32:47 -0400 Subject: [PATCH] test (cache/search): fix NewTestServer(...) storage (#5081) Fix ensures that the TestServer returned uses the correct directory for writing its sqlite files, which was created via t.TempDir() --- internal/clientcache/cmd/search/search_test.go | 4 ++-- internal/clientcache/internal/daemon/testing.go | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/internal/clientcache/cmd/search/search_test.go b/internal/clientcache/cmd/search/search_test.go index a19a283ff1c..ab14aedbfeb 100644 --- a/internal/clientcache/cmd/search/search_test.go +++ b/internal/clientcache/cmd/search/search_test.go @@ -136,9 +136,9 @@ func TestSearch(t *testing.T) { assert.Nil(t, apiErr) assert.NotNil(t, resp) assert.NotNil(t, r) - assert.EqualValues(t, r, &daemon.SearchResult{ + assert.EqualValues(t, &daemon.SearchResult{ RefreshStatus: daemon.NotRefreshing, - }) + }, r) }) t.Run("empty response from query", func(t *testing.T) { diff --git a/internal/clientcache/internal/daemon/testing.go b/internal/clientcache/internal/daemon/testing.go index b29ffc6b7d8..7faa91a8c21 100644 --- a/internal/clientcache/internal/daemon/testing.go +++ b/internal/clientcache/internal/daemon/testing.go @@ -37,6 +37,9 @@ func NewTestServer(t *testing.T, cmd Commander, opt ...Option) *TestServer { RecheckSupportInterval: DefaultRecheckSupportInterval, LogWriter: io.Discard, DotDirectory: dotDir, + // we need to provide this, otherwise it will open a store in the user's + // home dir. See db.Open(...) + DatabaseUrl: dotDir + "cache.db?_pragma=foreign_keys(1)", } s, err := New(ctx, cfg)