From 574c83e47f47fb52cf7c2f2c31ab0cbfef949d9f Mon Sep 17 00:00:00 2001 From: Michael Eischer Date: Sun, 15 Aug 2021 18:19:43 +0200 Subject: [PATCH] rest: Fix test to use paths which are the sha256 sum of the data --- internal/backend/test/tests.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/backend/test/tests.go b/internal/backend/test/tests.go index 05a41c616..8e1f78ca6 100644 --- a/internal/backend/test/tests.go +++ b/internal/backend/test/tests.go @@ -13,6 +13,7 @@ import ( "testing" "time" + "github.com/minio/sha256-simd" "github.com/restic/restic/internal/errors" "github.com/restic/restic/internal/restic" @@ -484,12 +485,11 @@ func (s *Suite) TestSave(t *testing.T) { for i := 0; i < saveTests; i++ { length := rand.Intn(1<<23) + 200000 data := test.Random(23, length) - // use the first 32 byte as the ID - copy(id[:], data) + id = sha256.Sum256(data) h := restic.Handle{ Type: restic.PackFile, - Name: fmt.Sprintf("%s-%d", id, i), + Name: id.String(), } err := b.Save(context.TODO(), h, restic.NewByteReader(data, b.Hasher())) test.OK(t, err) @@ -529,7 +529,7 @@ func (s *Suite) TestSave(t *testing.T) { length := rand.Intn(1<<23) + 200000 data := test.Random(23, length) - copy(id[:], data) + id = sha256.Sum256(data) if _, err = tmpfile.Write(data); err != nil { t.Fatal(err)