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

23 lines
388 B

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))
}