2020-09-29 14:30:22 +08:00
|
|
|
package proc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2023-04-29 20:36:29 +08:00
|
|
|
"github.com/zeromicro/go-zero/core/logx/logtest"
|
2020-09-29 14:30:22 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestProfile(t *testing.T) {
|
2023-04-29 20:36:29 +08:00
|
|
|
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()
|
2023-04-29 20:36:29 +08:00
|
|
|
assert.True(t, strings.Contains(c.String(), ".pprof"))
|
2020-09-29 14:30:22 +08:00
|
|
|
}
|