go-zero/core/proc/profile_test.go

21 lines
401 B
Go
Raw Normal View History

2020-09-29 14:30:22 +08:00
package proc
import (
"strings"
"testing"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/core/logx/logtest"
2020-09-29 14:30:22 +08:00
)
func TestProfile(t *testing.T) {
c := logtest.NewCollector(t)
2020-09-29 14:30:22 +08:00
profiler := StartProfile()
// start again should not work
assert.NotNil(t, StartProfile())
profiler.Stop()
// stop twice
profiler.Stop()
assert.True(t, strings.Contains(c.String(), ".pprof"))
2020-09-29 14:30:22 +08:00
}