From c0627dc80d66397747d6f5aa7210649b9906e5fc Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Mon, 1 May 2023 17:18:19 +0200 Subject: [PATCH 1/2] check: Fix flaky TestCheckerModifiedData The test had a 4% chance of not modified the data read from the repository, in which case the test would fail. Change the data manipulation to just modified each read operation. --- internal/checker/checker_test.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/internal/checker/checker_test.go b/internal/checker/checker_test.go index 775484652..6405ecfbd 100644 --- a/internal/checker/checker_test.go +++ b/internal/checker/checker_test.go @@ -331,10 +331,6 @@ func (erd errorReadCloser) Read(p []byte) (int, error) { // induceError flips a bit in the slice. func induceError(data []byte) { - if rand.Float32() < 0.2 { - return - } - pos := rand.Intn(len(data)) data[pos] ^= 1 } From 88a7231217ce3118eb3ffff5ee1f59f2f8c6ccc7 Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Mon, 1 May 2023 17:24:13 +0200 Subject: [PATCH 2/2] report snapshot id if loading failed --- internal/restic/snapshot.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/restic/snapshot.go b/internal/restic/snapshot.go index 58d863526..1f6e4534b 100644 --- a/internal/restic/snapshot.go +++ b/internal/restic/snapshot.go @@ -61,7 +61,7 @@ func LoadSnapshot(ctx context.Context, loader LoaderUnpacked, id ID) (*Snapshot, sn := &Snapshot{id: &id} err := LoadJSONUnpacked(ctx, loader, SnapshotFile, id, sn) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to load snapshot %v: %w", id.Str(), err) } return sn, nil