-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upstream ref: 8efb874f4887721b2df98eae2f6a831e09c0cc6a
- Loading branch information
Showing
27 changed files
with
594 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package local | ||
|
||
import ( | ||
"context" | ||
"errors" | ||
"os" | ||
"syscall" | ||
"testing" | ||
|
||
"github.com/rubiojr/rapi/restic" | ||
rtest "github.com/rubiojr/rapi/internal/test" | ||
|
||
"github.com/cenkalti/backoff/v4" | ||
) | ||
|
||
func TestNoSpacePermanent(t *testing.T) { | ||
oldOpenFile := openFile | ||
defer func() { | ||
openFile = oldOpenFile | ||
}() | ||
|
||
openFile = func(name string, flags int, mode os.FileMode) (*os.File, error) { | ||
// The actual error from os.OpenFile is *os.PathError. | ||
// Other functions called inside Save may return *os.SyscallError. | ||
return nil, os.NewSyscallError("open", syscall.ENOSPC) | ||
} | ||
|
||
dir, cleanup := rtest.TempDir(t) | ||
defer cleanup() | ||
|
||
be, err := Open(context.Background(), Config{Path: dir}) | ||
rtest.OK(t, err) | ||
defer be.Close() | ||
|
||
h := restic.Handle{Type: restic.ConfigFile} | ||
err = be.Save(context.Background(), h, nil) | ||
_, ok := err.(*backoff.PermanentError) | ||
rtest.Assert(t, ok, | ||
"error type should be backoff.PermanentError, got %T", err) | ||
rtest.Assert(t, errors.Is(err, syscall.ENOSPC), | ||
"could not recover original ENOSPC error") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.