1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-10 00:29:01 +02:00
kratos/pkg/stat/metric/gauge_test.go

24 lines
388 B
Go
Raw Normal View History

2019-04-12 15:07:26 +02:00
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))
}