From 91dcb958e079fa064aca4475dbba6aef90fe00c6 Mon Sep 17 00:00:00 2001 From: Alexander Neumann Date: Fri, 13 Jan 2017 12:40:03 +0100 Subject: [PATCH] Fix tests --- src/restic/archiver/archive_reader_test.go | 3 ++- src/restic/node.go | 3 ++- src/restic/repository/repository_test.go | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/restic/archiver/archive_reader_test.go b/src/restic/archiver/archive_reader_test.go index f2de24830..82a432f00 100644 --- a/src/restic/archiver/archive_reader_test.go +++ b/src/restic/archiver/archive_reader_test.go @@ -5,6 +5,7 @@ import ( "io" "math/rand" "restic" + "restic/crypto" "restic/repository" "testing" ) @@ -44,7 +45,7 @@ func checkSavedFile(t *testing.T, repo restic.Repository, treeID restic.ID, name t.Fatal(err) } - buf := make([]byte, int(size)) + buf := make([]byte, int(size), int(size)+crypto.Extension) n := loadBlob(t, repo, id, buf) if n != len(buf) { t.Errorf("wrong number of bytes read, want %d, got %d", len(buf), n) diff --git a/src/restic/node.go b/src/restic/node.go index e17215125..82de2bd6a 100644 --- a/src/restic/node.go +++ b/src/restic/node.go @@ -10,6 +10,7 @@ import ( "syscall" "time" + "restic/crypto" "restic/errors" "runtime" @@ -208,7 +209,7 @@ func (node Node) createFileAt(path string, repo Repository) error { buf = buf[:cap(buf)] if uint(len(buf)) < size { - buf = make([]byte, size) + buf = make([]byte, size, size+crypto.Extension) } n, err := repo.LoadBlob(DataBlob, id, buf) diff --git a/src/restic/repository/repository_test.go b/src/restic/repository/repository_test.go index 978537d7f..b2f04ab1d 100644 --- a/src/restic/repository/repository_test.go +++ b/src/restic/repository/repository_test.go @@ -41,7 +41,7 @@ func TestSave(t *testing.T) { // OK(t, repo.SaveIndex()) // read back - buf := make([]byte, size) + buf := make([]byte, size, size+crypto.Extension) n, err := repo.LoadBlob(restic.DataBlob, id, buf) OK(t, err) Equals(t, len(buf), n) @@ -75,7 +75,7 @@ func TestSaveFrom(t *testing.T) { OK(t, repo.Flush()) // read back - buf := make([]byte, size) + buf := make([]byte, size, size+crypto.Extension) n, err := repo.LoadBlob(restic.DataBlob, id, buf) OK(t, err) Equals(t, len(buf), n)