2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-23 11:28:54 +00:00

Fix test for PackerManager

This commit is contained in:
Alexander Neumann 2017-01-23 18:49:12 +01:00
parent 8e722d8fee
commit 0d95507909
2 changed files with 19 additions and 8 deletions

View File

@ -29,6 +29,20 @@ type Packer struct {
tmpfile *os.File tmpfile *os.File
} }
// Finalize finalizes the pack.Packer and then closes the tempfile.
func (p *Packer) Finalize() (uint, error) {
n, err := p.Packer.Finalize()
if err != nil {
return n, err
}
if err = p.tmpfile.Close(); err != nil {
return n, err
}
return n, nil
}
// packerManager keeps a list of open packs and creates new on demand. // packerManager keeps a list of open packs and creates new on demand.
type packerManager struct { type packerManager struct {
be Saver be Saver

View File

@ -53,17 +53,14 @@ func saveFile(t testing.TB, be Saver, filename string, id restic.ID) {
t.Fatal(err) t.Fatal(err)
} }
defer func() {
if err := f.Close(); err != nil {
t.Fatal(err)
}
}()
h := restic.Handle{Type: restic.DataFile, Name: id.String()} h := restic.Handle{Type: restic.DataFile, Name: id.String()}
t.Logf("save file %v", h) t.Logf("save file %v", h)
err = be.Save(h, f) if err = be.Save(h, f); err != nil {
if err != nil { t.Fatal(err)
}
if err = f.Close(); err != nil {
t.Fatal(err) t.Fatal(err)
} }