-
Notifications
You must be signed in to change notification settings - Fork 40
/
stack_test.go
40 lines (34 loc) · 1017 Bytes
/
stack_test.go
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
package gobrake
import (
testpkg1 "github.com/airbrake/gobrake/v5/internal/testpkg1"
testpkg2 "github.com/airbrake/gobrake/v5/internal/testpkg2"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/pkg/errors"
)
var _ = Describe("backtraceFromErrorWithStackTrace", func() {
It("returns package name", func() {
var tests = []struct {
err error
packageName string
}{{
err: testpkg1.Foo(),
packageName: "github.com/airbrake/gobrake/v5/internal/testpkg1",
}, {
err: testpkg1.Bar(),
packageName: "github.com/airbrake/gobrake/v5/internal/testpkg1",
}, {
err: testpkg2.NewError(),
packageName: "github.com/airbrake/gobrake/v5/internal/testpkg2",
}}
type stackTracer interface {
StackTrace() errors.StackTrace
}
for _, test := range tests {
v, ok := test.err.(stackTracer)
Expect(ok).To(BeTrue())
packageName, _ := backtraceFromErrorWithStackTrace(v)
Expect(packageName).To(Equal(test.packageName))
}
})
})