2
2
mirror of https://github.com/octoleo/restic.git synced 2024-11-30 00:33:57 +00:00

tests: Add test for backend Save() from file

This commit is contained in:
Alexander Neumann 2017-05-14 00:15:17 +02:00
parent 9dd58196e3
commit be0e53c07b

View File

@ -293,7 +293,7 @@ func (s *Suite) TestSave(t *testing.T) {
t.Fatal(err)
}
if _, err = tmpfile.Seek(0, 0); err != nil {
if _, err = tmpfile.Seek(0, io.SeekStart); err != nil {
t.Fatal(err)
}
@ -306,11 +306,22 @@ func (s *Suite) TestSave(t *testing.T) {
t.Fatal(err)
}
if err = tmpfile.Close(); err != nil {
err = b.Remove(h)
if err != nil {
t.Fatalf("error removing item: %+v", err)
}
// try again directly with the temp file
if _, err = tmpfile.Seek(588, io.SeekStart); err != nil {
t.Fatal(err)
}
if err = os.Remove(tmpfile.Name()); err != nil {
err = b.Save(h, tmpfile)
if err != nil {
t.Fatal(err)
}
if err = tmpfile.Close(); err != nil {
t.Fatal(err)
}
@ -318,6 +329,10 @@ func (s *Suite) TestSave(t *testing.T) {
if err != nil {
t.Fatalf("error removing item: %+v", err)
}
if err = os.Remove(tmpfile.Name()); err != nil {
t.Fatal(err)
}
}
var filenameTests = []struct {