2
2
mirror of https://github.com/octoleo/restic.git synced 2024-12-05 03:13:18 +00:00
restic/internal/fs/node_xattr_test.go
2024-08-31 17:37:25 +02:00

29 lines
758 B
Go

//go:build darwin || freebsd || linux || solaris
// +build darwin freebsd linux solaris
package fs
import (
"os"
"testing"
"github.com/pkg/xattr"
rtest "github.com/restic/restic/internal/test"
)
func TestIsListxattrPermissionError(t *testing.T) {
xerr := &xattr.Error{
Op: "xattr.list",
Name: "test",
Err: os.ErrPermission,
}
err := handleXattrErr(xerr)
rtest.Assert(t, err != nil, "missing error")
rtest.Assert(t, isListxattrPermissionError(err), "expected IsListxattrPermissionError to return true for %v", err)
xerr.Err = os.ErrNotExist
err = handleXattrErr(xerr)
rtest.Assert(t, err != nil, "missing error")
rtest.Assert(t, !isListxattrPermissionError(err), "expected IsListxattrPermissionError to return false for %v", err)
}