MCPcopy
hub / github.com/uber-go/goleak / TestCurrent

Function TestCurrent

internal/stack/stacks_test.go:83–115  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

81}
82
83func TestCurrent(t *testing.T) {
84 const pkgPrefix = "go.uber.org/goleak/internal/stack"
85
86 got := Current()
87 assert.NotZero(t, got.ID(), "Should get non-zero goroutine id")
88 assert.Equal(t, "running", got.State())
89 assert.Equal(t, "go.uber.org/goleak/internal/stack.getStackBuffer", got.FirstFunction())
90
91 wantFrames := []string{
92 "getStackBuffer",
93 "getStacks",
94 "Current",
95 "Current",
96 "TestCurrent",
97 }
98 all := got.Full()
99 for _, frame := range wantFrames {
100 name := pkgPrefix + "." + frame
101 assert.Contains(t, all, name)
102 assert.True(t, got.HasFunction(name), "missing in stack: %v\n%s", name, all)
103 }
104 assert.Contains(t, got.String(), "in state")
105 assert.Contains(t, got.String(), "on top of the stack")
106
107 assert.Contains(t, all, "stack/stacks_test.go",
108 "file name missing in stack:\n%s", all)
109
110 // Ensure that we are not returning the buffer without slicing it
111 // from getStackBuffer.
112 if len(got.Full()) > 1024 {
113 t.Fatalf("Returned stack is too large")
114 }
115}
116
117func TestCurrentCreatedBy(t *testing.T) {
118 var stack Stack

Callers

nothing calls this directly

Calls 7

CurrentFunction · 0.85
IDMethod · 0.80
StateMethod · 0.80
FirstFunctionMethod · 0.80
FullMethod · 0.80
HasFunctionMethod · 0.80
StringMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…