Move pack testing logic to test file

This commit is contained in:
greatroar 2020-07-22 23:53:55 +02:00 committed by Alexander Neumann
parent 913a34f568
commit 9a8a2cae4c
2 changed files with 3 additions and 8 deletions

View File

@ -151,11 +151,6 @@ func (p *Packer) Blobs() []restic.Blob {
return p.blobs
}
// Writer return the underlying writer.
func (p *Packer) Writer() io.Writer {
return p.wr
}
func (p *Packer) String() string {
return fmt.Sprintf("<Packer %d blobs, %d bytes>", len(p.blobs), p.bytes)
}

View File

@ -36,7 +36,8 @@ func newPack(t testing.TB, k *crypto.Key, lengths []int) ([]Buf, []byte, uint) {
}
// pack blobs
p := pack.NewPacker(k, new(bytes.Buffer))
var buf bytes.Buffer
p := pack.NewPacker(k, &buf)
for _, b := range bufs {
p.Add(restic.TreeBlob, b.id, b.data)
}
@ -44,8 +45,7 @@ func newPack(t testing.TB, k *crypto.Key, lengths []int) ([]Buf, []byte, uint) {
_, err := p.Finalize()
rtest.OK(t, err)
packData := p.Writer().(*bytes.Buffer).Bytes()
return bufs, packData, p.Size()
return bufs, buf.Bytes(), p.Size()
}
func verifyBlobs(t testing.TB, bufs []Buf, k *crypto.Key, rd io.ReaderAt, packSize uint) {