Merge pull request #2933 from MichaelEischer/less-context-todo

Replace most usages of context.TODO()
This commit is contained in:
Alexander Neumann
2020-10-10 15:03:44 +02:00
committed by GitHub
42 changed files with 118 additions and 111 deletions

View File

@@ -179,26 +179,26 @@ func TestFileRestorerBasic(t *testing.T) {
defer cleanup()
restoreAndVerify(t, tempdir, []TestFile{
TestFile{
{
name: "file1",
blobs: []TestBlob{
TestBlob{"data1-1", "pack1-1"},
TestBlob{"data1-2", "pack1-2"},
{"data1-1", "pack1-1"},
{"data1-2", "pack1-2"},
},
},
TestFile{
{
name: "file2",
blobs: []TestBlob{
TestBlob{"data2-1", "pack2-1"},
TestBlob{"data2-2", "pack2-2"},
{"data2-1", "pack2-1"},
{"data2-2", "pack2-2"},
},
},
TestFile{
{
name: "file3",
blobs: []TestBlob{
// same blob multiple times
TestBlob{"data3-1", "pack3-1"},
TestBlob{"data3-1", "pack3-1"},
{"data3-1", "pack3-1"},
{"data3-1", "pack3-1"},
},
},
})

View File

@@ -24,7 +24,7 @@ type Restorer struct {
var restorerAbortOnAllErrors = func(location string, err error) error { return err }
// NewRestorer creates a restorer preloaded with the content from the snapshot id.
func NewRestorer(repo restic.Repository, id restic.ID) (*Restorer, error) {
func NewRestorer(ctx context.Context, repo restic.Repository, id restic.ID) (*Restorer, error) {
r := &Restorer{
repo: repo,
Error: restorerAbortOnAllErrors,
@@ -33,7 +33,7 @@ func NewRestorer(repo restic.Repository, id restic.ID) (*Restorer, error) {
var err error
r.sn, err = restic.LoadSnapshot(context.TODO(), repo, id)
r.sn, err = restic.LoadSnapshot(ctx, repo, id)
if err != nil {
return nil, err
}

View File

@@ -326,7 +326,7 @@ func TestRestorer(t *testing.T) {
_, id := saveSnapshot(t, repo, test.Snapshot)
t.Logf("snapshot saved as %v", id.Str())
res, err := NewRestorer(repo, id)
res, err := NewRestorer(context.TODO(), repo, id)
if err != nil {
t.Fatal(err)
}
@@ -444,7 +444,7 @@ func TestRestorerRelative(t *testing.T) {
_, id := saveSnapshot(t, repo, test.Snapshot)
t.Logf("snapshot saved as %v", id.Str())
res, err := NewRestorer(repo, id)
res, err := NewRestorer(context.TODO(), repo, id)
if err != nil {
t.Fatal(err)
}
@@ -676,7 +676,7 @@ func TestRestorerTraverseTree(t *testing.T) {
defer cleanup()
sn, id := saveSnapshot(t, repo, test.Snapshot)
res, err := NewRestorer(repo, id)
res, err := NewRestorer(context.TODO(), repo, id)
if err != nil {
t.Fatal(err)
}

View File

@@ -29,7 +29,7 @@ func TestRestorerRestoreEmptyHardlinkedFileds(t *testing.T) {
},
})
res, err := NewRestorer(repo, id)
res, err := NewRestorer(context.TODO(), repo, id)
rtest.OK(t, err)
res.SelectFilter = func(item string, dstpath string, node *restic.Node) (selectedForRestore bool, childMayBeSelected bool) {