rest: Fix test to use paths which are the sha256 sum of the data

This commit is contained in:
Michael Eischer 2021-08-15 18:19:43 +02:00
parent e6a5801155
commit 574c83e47f
1 changed files with 4 additions and 4 deletions

View File

@ -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)