alert_test.go 323 B

12345678910111213141516171819202122
  1. // +build linux
  2. package stat
  3. import (
  4. "strconv"
  5. "sync/atomic"
  6. "testing"
  7. "github.com/stretchr/testify/assert"
  8. )
  9. func TestReport(t *testing.T) {
  10. var count int32
  11. SetReporter(func(s string) {
  12. atomic.AddInt32(&count, 1)
  13. })
  14. for i := 0; i < 10; i++ {
  15. Report(strconv.Itoa(i))
  16. }
  17. assert.Equal(t, int32(1), count)
  18. }