1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-07-01 19:45:24 +00:00
v2fly/app/stats/stats_test.go

33 lines
627 B
Go
Raw Normal View History

2018-03-30 17:56:59 +00:00
package stats_test
import (
2018-03-30 21:17:28 +00:00
"context"
2018-03-30 17:56:59 +00:00
"testing"
"v2ray.com/core"
. "v2ray.com/core/app/stats"
2018-03-30 21:17:28 +00:00
"v2ray.com/core/common"
2018-03-30 17:56:59 +00:00
. "v2ray.com/ext/assert"
)
func TestInternface(t *testing.T) {
assert := With(t)
assert((*Manager)(nil), Implements, (*core.StatManager)(nil))
}
2018-03-30 21:17:28 +00: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))
}