-
Notifications
You must be signed in to change notification settings - Fork 1
/
stack_trace_test.go
48 lines (36 loc) · 979 Bytes
/
stack_trace_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
41
42
43
44
45
46
47
48
package logy
import (
"fmt"
"github.com/stretchr/testify/assert"
"runtime"
"testing"
)
var (
_, stackTraceFilename, _, _ = runtime.Caller(0)
)
func TestCaptureFirstStacktrace(t *testing.T) {
var (
buf []byte
)
stack := captureStacktrace(0, stackTraceFirst)
frame, more := stack.next()
formatFrame(&buf, 0, frame)
i := 1
for frame, more = stack.next(); more; frame, more = stack.next() {
formatFrame(&buf, i, frame)
}
assert.Equal(t, fmt.Sprintf("codnect.io/logy.TestCaptureFirstStacktrace()\\n %s:19", stackTraceFilename), string(buf))
}
func TestCaptureFullStacktrace(t *testing.T) {
var (
buf []byte
)
stack := captureStacktrace(0, stackTraceFull)
frame, more := stack.next()
formatFrame(&buf, 0, frame)
i := 1
for frame, more = stack.next(); more; frame, more = stack.next() {
formatFrame(&buf, i, frame)
}
assert.Equal(t, fmt.Sprintf("codnect.io/logy.TestCaptureFullStacktrace()\\n %s:37", stackTraceFilename), string(buf))
}