Debian Codegraph @

pathrs-lite/internal/gocompat/gocompat_errors_test.go

raw
1 // SPDX-License-Identifier: BSD-3-Clause
2
3 //go:build linux
4
5 // Copyright (C) 2024 SUSE LLC. All rights reserved.
6 // Use of this source code is governed by a BSD-style
7 // license that can be found in the LICENSE file.
8
9 package gocompat
10
11 import (
12 "errors"
13 "testing"
14
15 "github.com/stretchr/testify/assert"
16 "github.com/stretchr/testify/require"
17 )
18
19 func TestGoCompatErrorWrap(t *testing.T) {
20 baseErr := errors.New("base error")
21 extraErr := errors.New("extra error")
22
23 err := WrapBaseError(baseErr, extraErr)
24
25 require.Error(t, err)
26 assert.ErrorIs(t, err, baseErr, "wrapped error should contain base error") //nolint:testifylint // we are testing error behaviour directly
27 assert.ErrorIs(t, err, extraErr, "wrapped error should contain extra error") //nolint:testifylint // we are testing error behaviour directly
28 }