You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kratos/pkg/stat/metric/gauge_test.go

24 lines
388 B

6 years ago
package metric
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestGaugeAdd(t *testing.T) {
gauge := NewGauge(GaugeOpts{})
gauge.Add(100)
gauge.Add(-50)
val := gauge.Value()
assert.Equal(t, val, int64(50))
}
func TestGaugeSet(t *testing.T) {
gauge := NewGauge(GaugeOpts{})
gauge.Add(100)
gauge.Set(50)
val := gauge.Value()
assert.Equal(t, val, int64(50))
}