Skip to content

Commit a11565d

Browse files
authored
Merge pull request #91 from thaJeztah/breakout_unwrap
archive: make breakoutErr unwrap its cause
2 parents b680a61 + e122aad commit a11565d

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

archive.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ func breakoutError(err error) error {
123123
return &breakoutErr{error: err}
124124
}
125125

126+
func (e *breakoutErr) Unwrap() error { return e.error }
127+
126128
const (
127129
AUFSWhiteoutFormat WhiteoutFormat = 0 // AUFSWhiteoutFormat is the default format for whiteouts
128130
OverlayWhiteoutFormat WhiteoutFormat = 1 // OverlayWhiteoutFormat formats whiteout according to the overlay standard.

archive_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@ func createTarFromFiles(t *testing.T, tarPath string, files ...string) {
7777
assert.NilError(t, f.Close())
7878
}
7979

80+
func TestBreakoutErrorUnwrap(t *testing.T) {
81+
sentinel := errors.New("sentinel")
82+
err := breakoutError(sentinel)
83+
84+
assert.Check(t, is.ErrorType(err, &breakoutErr{}))
85+
assert.Check(t, is.ErrorIs(err, sentinel))
86+
}
87+
8088
func TestIsArchivePathDir(t *testing.T) {
8189
tmp := t.TempDir()
8290
assert.NilError(t, os.Mkdir(filepath.Join(tmp, "archivedir"), 0o755))

0 commit comments

Comments
 (0)