mirror of
https://github.com/octoleo/restic.git
synced 2024-11-15 17:47:21 +00:00
Move pack testing logic to test file
This commit is contained in:
parent
913a34f568
commit
9a8a2cae4c
@ -151,11 +151,6 @@ func (p *Packer) Blobs() []restic.Blob {
|
|||||||
return p.blobs
|
return p.blobs
|
||||||
}
|
}
|
||||||
|
|
||||||
// Writer return the underlying writer.
|
|
||||||
func (p *Packer) Writer() io.Writer {
|
|
||||||
return p.wr
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *Packer) String() string {
|
func (p *Packer) String() string {
|
||||||
return fmt.Sprintf("<Packer %d blobs, %d bytes>", len(p.blobs), p.bytes)
|
return fmt.Sprintf("<Packer %d blobs, %d bytes>", len(p.blobs), p.bytes)
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,8 @@ func newPack(t testing.TB, k *crypto.Key, lengths []int) ([]Buf, []byte, uint) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// pack blobs
|
// pack blobs
|
||||||
p := pack.NewPacker(k, new(bytes.Buffer))
|
var buf bytes.Buffer
|
||||||
|
p := pack.NewPacker(k, &buf)
|
||||||
for _, b := range bufs {
|
for _, b := range bufs {
|
||||||
p.Add(restic.TreeBlob, b.id, b.data)
|
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()
|
_, err := p.Finalize()
|
||||||
rtest.OK(t, err)
|
rtest.OK(t, err)
|
||||||
|
|
||||||
packData := p.Writer().(*bytes.Buffer).Bytes()
|
return bufs, buf.Bytes(), p.Size()
|
||||||
return bufs, packData, p.Size()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyBlobs(t testing.TB, bufs []Buf, k *crypto.Key, rd io.ReaderAt, packSize uint) {
|
func verifyBlobs(t testing.TB, bufs []Buf, k *crypto.Key, rd io.ReaderAt, packSize uint) {
|
||||||
|
Loading…
Reference in New Issue
Block a user