-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patherrors_is_test.go
More file actions
46 lines (41 loc) · 918 Bytes
/
errors_is_test.go
File metadata and controls
46 lines (41 loc) · 918 Bytes
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
// 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 (
"context"
stderrors "errors"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/bborbe/errors"
)
var _ = Describe("Is", func() {
var err error
var target error
var is bool
var ctx context.Context
BeforeEach(func() {
ctx = context.Background()
})
JustBeforeEach(func() {
is = stderrors.Is(err, target)
})
Context("same", func() {
BeforeEach(func() {
err = context.Canceled
target = context.Canceled
})
It("returns true", func() {
Expect(is).To(BeTrue())
})
})
Context("wrapped", func() {
BeforeEach(func() {
err = errors.Wrapf(ctx, context.Canceled, "banana")
target = context.Canceled
})
It("returns true", func() {
Expect(is).To(BeTrue())
})
})
})