-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherrors_unwrap_test.go
More file actions
56 lines (50 loc) · 1.19 KB
/
errors_unwrap_test.go
File metadata and controls
56 lines (50 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 2023 Benjamin Borbe All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package errors_test
import (
stderrors "errors"
"fmt"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
liberrors "github.com/bborbe/errors"
)
var _ = Describe("Unwrap", func() {
var err error
var result error
JustBeforeEach(func() {
result = liberrors.Unwrap(err)
})
Context("nil", func() {
BeforeEach(func() {
err = nil
})
It("returns no error", func() {
Expect(result).To(BeNil())
})
})
Context("not wrapped", func() {
BeforeEach(func() {
err = stderrors.New("banana")
})
It("returns correct error", func() {
Expect(result).To(Equal(stderrors.New("banana")))
})
})
Context("fmt wrapped", func() {
BeforeEach(func() {
err = fmt.Errorf("bla: %w", stderrors.New("banana"))
})
It("returns correct error", func() {
Expect(result).To(Equal(stderrors.New("banana")))
})
})
Context("join wrapped", func() {
BeforeEach(func() {
err = stderrors.Join(stderrors.New("banana"))
})
It("returns correct error", func() {
Expect(result).To(Equal(stderrors.New("banana")))
})
})
})