1
0
Fork 0

Adding upstream version 3.5.1.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-18 18:07:37 +02:00
parent e37d4622a7
commit 097626e61a
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
57 changed files with 6023 additions and 0 deletions

54
error_test.go Normal file
View file

@ -0,0 +1,54 @@
package archiver_test
import (
"errors"
"fmt"
"os"
"testing"
"github.com/mholt/archiver/v3"
)
func TestIllegalPathErrorString(t *testing.T) {
tests := []struct {
instance *archiver.IllegalPathError
expected string
}{
{instance: &archiver.IllegalPathError{Filename: "foo.txt"}, expected: "illegal file path: foo.txt"},
{instance: &archiver.IllegalPathError{AbsolutePath: "/tmp/bar.txt", Filename: "bar.txt"}, expected: "illegal file path: bar.txt"},
}
for i, test := range tests {
test := test
t.Run(fmt.Sprintf("Case %d", i), func(t *testing.T) {
if test.expected != test.instance.Error() {
t.Fatalf("Excepected '%s', but got '%s'", test.expected, test.instance.Error())
}
})
}
}
func TestIsIllegalPathError(t *testing.T) {
tests := []struct {
instance error
expected bool
}{
{instance: nil, expected: false},
{instance: os.ErrNotExist, expected: false},
{instance: fmt.Errorf("some error"), expected: false},
{instance: errors.New("another error"), expected: false},
{instance: &archiver.IllegalPathError{Filename: "foo.txt"}, expected: true},
}
for i, test := range tests {
test := test
t.Run(fmt.Sprintf("Case %d", i), func(t *testing.T) {
actual := archiver.IsIllegalPathError(test.instance)
if actual != test.expected {
t.Fatalf("Excepected '%v', but got '%v'", test.expected, actual)
}
})
}
}