Fix nil context being passed to function

This commit is contained in:
deepsource-autofix[bot] 2021-06-07 03:24:32 +00:00 committed by Matt Joiner
parent 56e5d08eff
commit a68f040ea6
2 changed files with 4 additions and 3 deletions

View File

@ -252,7 +252,7 @@ func NewPiecesStorage(opts NewPiecesStorageOpts) (_ storage.ClientImplCloser, er
if opts.SetJournalMode == "" && !opts.Memory {
opts.SetJournalMode = "wal"
}
err = initPoolConns(nil, conns, opts.InitConnOpts)
err = initPoolConns(context.TODO(), conns, opts.InitConnOpts)
if err != nil {
conns.Close()
return
@ -494,7 +494,7 @@ type ConnPool interface {
}
func withPoolConn(pool ConnPool, with func(conn)) {
c := pool.Get(nil)
c := pool.Get(context.TODO())
defer pool.Put(c)
with(c)
}

View File

@ -5,6 +5,7 @@ package sqliteStorage
import (
"bytes"
"context"
"errors"
"fmt"
"io"
@ -34,7 +35,7 @@ func newConnsAndProv(t *testing.T, opts NewPoolOpts) (ConnPool, *provider) {
if !opts.Memory && opts.SetJournalMode == "" {
opts.SetJournalMode = "wal"
}
qt.Assert(t, initPoolConns(nil, pool, opts.InitConnOpts), qt.IsNil)
qt.Assert(t, initPoolConns(context.TODO(), pool, opts.InitConnOpts), qt.IsNil)
prov, err := NewProvider(pool, ProviderOpts{BatchWrites: pool.NumConns() > 1})
require.NoError(t, err)
t.Cleanup(func() { prov.Close() })