(t *testing.T)
| 81 | } |
| 82 | |
| 83 | func 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 | |
| 117 | func TestCurrentCreatedBy(t *testing.T) { |
| 118 | var stack Stack |
nothing calls this directly
no test coverage detected
searching dependent graphs…