mirror of
https://github.com/octoleo/restic.git
synced 2024-11-30 00:33:57 +00:00
Fix tests
This commit is contained in:
parent
9a5b9253c4
commit
91dcb958e0
@ -5,6 +5,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"restic"
|
"restic"
|
||||||
|
"restic/crypto"
|
||||||
"restic/repository"
|
"restic/repository"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
@ -44,7 +45,7 @@ func checkSavedFile(t *testing.T, repo restic.Repository, treeID restic.ID, name
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := make([]byte, int(size))
|
buf := make([]byte, int(size), int(size)+crypto.Extension)
|
||||||
n := loadBlob(t, repo, id, buf)
|
n := loadBlob(t, repo, id, buf)
|
||||||
if n != len(buf) {
|
if n != len(buf) {
|
||||||
t.Errorf("wrong number of bytes read, want %d, got %d", len(buf), n)
|
t.Errorf("wrong number of bytes read, want %d, got %d", len(buf), n)
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"restic/crypto"
|
||||||
"restic/errors"
|
"restic/errors"
|
||||||
|
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -208,7 +209,7 @@ func (node Node) createFileAt(path string, repo Repository) error {
|
|||||||
|
|
||||||
buf = buf[:cap(buf)]
|
buf = buf[:cap(buf)]
|
||||||
if uint(len(buf)) < size {
|
if uint(len(buf)) < size {
|
||||||
buf = make([]byte, size)
|
buf = make([]byte, size, size+crypto.Extension)
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := repo.LoadBlob(DataBlob, id, buf)
|
n, err := repo.LoadBlob(DataBlob, id, buf)
|
||||||
|
@ -41,7 +41,7 @@ func TestSave(t *testing.T) {
|
|||||||
// OK(t, repo.SaveIndex())
|
// OK(t, repo.SaveIndex())
|
||||||
|
|
||||||
// read back
|
// read back
|
||||||
buf := make([]byte, size)
|
buf := make([]byte, size, size+crypto.Extension)
|
||||||
n, err := repo.LoadBlob(restic.DataBlob, id, buf)
|
n, err := repo.LoadBlob(restic.DataBlob, id, buf)
|
||||||
OK(t, err)
|
OK(t, err)
|
||||||
Equals(t, len(buf), n)
|
Equals(t, len(buf), n)
|
||||||
@ -75,7 +75,7 @@ func TestSaveFrom(t *testing.T) {
|
|||||||
OK(t, repo.Flush())
|
OK(t, repo.Flush())
|
||||||
|
|
||||||
// read back
|
// read back
|
||||||
buf := make([]byte, size)
|
buf := make([]byte, size, size+crypto.Extension)
|
||||||
n, err := repo.LoadBlob(restic.DataBlob, id, buf)
|
n, err := repo.LoadBlob(restic.DataBlob, id, buf)
|
||||||
OK(t, err)
|
OK(t, err)
|
||||||
Equals(t, len(buf), n)
|
Equals(t, len(buf), n)
|
||||||
|
Loading…
Reference in New Issue
Block a user