xframe/base/stat/alert_test.go

25 lines
367 B
Go
Raw Normal View History

2024-10-12 12:55:20 +08:00
//go:build linux
package stat
import (
"strconv"
"sync/atomic"
"testing"
"github.com/stretchr/testify/assert"
)
func TestReport(t *testing.T) {
t.Setenv(clusterNameKey, "test-cluster")
var count int32
SetReporter(func(s string) {
atomic.AddInt32(&count, 1)
})
for i := 0; i < 10; i++ {
Report(strconv.Itoa(i))
}
assert.Equal(t, int32(1), count)
}