alert_test.go 367 B

123456789101112131415161718192021222324
  1. //go: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. t.Setenv(clusterNameKey, "test-cluster")
  11. var count int32
  12. SetReporter(func(s string) {
  13. atomic.AddInt32(&count, 1)
  14. })
  15. for i := 0; i < 10; i++ {
  16. Report(strconv.Itoa(i))
  17. }
  18. assert.Equal(t, int32(1), count)
  19. }