Skip to content

Commit

Permalink
test (cache/search): fix NewTestServer(...) storage (#5081)
Browse files Browse the repository at this point in the history
Fix ensures that the TestServer returned uses the
correct directory for writing its sqlite files,
which was created via t.TempDir()

(cherry picked from commit 85f9104)
  • Loading branch information
jimlambrt authored and tmessi committed Sep 24, 2024
1 parent 829ea02 commit 863359a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/clientcache/cmd/search/search_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,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) {
Expand Down
3 changes: 3 additions & 0 deletions internal/clientcache/internal/daemon/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 863359a

Please sign in to comment.