profile_test.go 376 B

123456789101112131415161718192021
  1. package proc
  2. import (
  3. "log"
  4. "strings"
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. func TestProfile(t *testing.T) {
  9. var buf strings.Builder
  10. log.SetOutput(&buf)
  11. profiler := StartProfile()
  12. // start again should not work
  13. assert.NotNil(t, StartProfile())
  14. profiler.Stop()
  15. // stop twice
  16. profiler.Stop()
  17. assert.True(t, strings.Contains(buf.String(), ".pprof"))
  18. }