Debian Codegraph @

pathrs-lite/internal/errors_linux_test.go

raw
1 // SPDX-License-Identifier: MPL-2.0
2
3 //go:build linux
4
5 // Copyright (C) 2024-2025 Aleksa Sarai <[email protected]>
6 // Copyright (C) 2024-2025 SUSE LLC
7 //
8 // This Source Code Form is subject to the terms of the Mozilla Public
9 // License, v. 2.0. If a copy of the MPL was not distributed with this
10 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
11
12 package internal
13
14 import (
15 "fmt"
16 "testing"
17
18 "github.com/stretchr/testify/assert"
19 "golang.org/x/sys/unix"
20 )
21
22 func TestErrorXdev(t *testing.T) {
23 for _, test := range []struct {
24 name string
25 err error
26 }{
27 {"ErrPossibleAttack", ErrPossibleAttack},
28 {"ErrPossibleBreakout", ErrPossibleBreakout},
29 } {
30 t.Run(test.name, func(t *testing.T) {
31 assert.ErrorIs(t, test.err, test.err, "errors.Is(err, err) should succeed") //nolint:useless-assert,testifylint // we need to check this
32 assert.ErrorIs(t, test.err, unix.EXDEV, "errors.Is(err, EXDEV) should succeed") //nolint:useless-assert,testifylint // we need to check this
33 })
34
35 t.Run(test.name+"-Wrapped", func(t *testing.T) {
36 err := fmt.Errorf("wrapped error: %w", test.err)
37 assert.ErrorIs(t, err, test.err, "errors.Is(err, err) should succeed") //nolint:useless-assert,testifylint // we need to check this
38 assert.ErrorIs(t, err, unix.EXDEV, "errors.Is(err, EXDEV) should succeed") //nolint:useless-assert,testifylint // we need to check this
39 })
40 }
41 }