From 360fbfd0faa5db00c0c3f1817fb0436ca440c73d Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 7 Oct 2020 23:02:58 +0800 Subject: [PATCH] add more tests --- core/stat/alert_test.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 core/stat/alert_test.go diff --git a/core/stat/alert_test.go b/core/stat/alert_test.go new file mode 100644 index 00000000..26c17787 --- /dev/null +++ b/core/stat/alert_test.go @@ -0,0 +1,22 @@ +// +build linux + +package stat + +import ( + "strconv" + "sync/atomic" + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestReport(t *testing.T) { + 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) +}