github.com/shuguocloud/go-zero@v1.3.0/core/stat/alert_test.go (about)

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