1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-11-19 02:46:33 -05:00
v2fly/app/stats/stats_test.go

33 lines
627 B
Go
Raw Normal View History

2018-03-30 13:56:59 -04:00
package stats_test
import (
2018-03-30 17:17:28 -04:00
"context"
2018-03-30 13:56:59 -04:00
"testing"
"v2ray.com/core"
. "v2ray.com/core/app/stats"
2018-03-30 17:17:28 -04:00
"v2ray.com/core/common"
2018-03-30 13:56:59 -04:00
. "v2ray.com/ext/assert"
)
func TestInternface(t *testing.T) {
assert := With(t)
assert((*Manager)(nil), Implements, (*core.StatManager)(nil))
}
2018-03-30 17:17:28 -04:00
func TestStatsCounter(t *testing.T) {
assert := With(t)
raw, err := common.CreateObject(context.Background(), &Config{})
assert(err, IsNil)
m := raw.(core.StatManager)
c, err := m.RegisterCounter("test.counter")
assert(err, IsNil)
assert(c.Add(1), Equals, int64(1))
assert(c.Set(0), Equals, int64(1))
assert(c.Value(), Equals, int64(0))
}