profile_test.go 409 B

1234567891011121314151617181920
  1. package proc
  2. import (
  3. "strings"
  4. "testing"
  5. "github.com/stretchr/testify/assert"
  6. "github.com/wuntsong-org/go-zero-plus/core/logx/logtest"
  7. )
  8. func TestProfile(t *testing.T) {
  9. c := logtest.NewCollector(t)
  10. profiler := StartProfile()
  11. // start again should not work
  12. assert.NotNil(t, StartProfile())
  13. profiler.Stop()
  14. // stop twice
  15. profiler.Stop()
  16. assert.True(t, strings.Contains(c.String(), ".pprof"))
  17. }