mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-10 00:29:01 +02:00
19 lines
299 B
Go
19 lines
299 B
Go
package metric
|
|
|
|
import (
|
|
"math/rand"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestCounter(t *testing.T) {
|
|
counter := NewCounter(CounterOpts{})
|
|
count := rand.Intn(100)
|
|
for i := 0; i < count; i++ {
|
|
counter.Add(1)
|
|
}
|
|
val := counter.Value()
|
|
assert.Equal(t, val, int64(count))
|
|
}
|