Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(757)

Side by Side Diff: common/tsmon/metric/metric_test.go

Issue 1857643003: Revert of Migrate tsmon protos to proto3 (Closed) Base URL: git@github.com:luci/luci-go.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « common/tsmon/flush_test.go ('k') | common/tsmon/monitor/acq.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package metric 5 package metric
6 6
7 import ( 7 import (
8 "testing" 8 "testing"
9 9
10 "github.com/golang/protobuf/proto"
10 "github.com/luci/luci-go/common/tsmon" 11 "github.com/luci/luci-go/common/tsmon"
11 "github.com/luci/luci-go/common/tsmon/distribution" 12 "github.com/luci/luci-go/common/tsmon/distribution"
12 "github.com/luci/luci-go/common/tsmon/monitor" 13 "github.com/luci/luci-go/common/tsmon/monitor"
13 "github.com/luci/luci-go/common/tsmon/store" 14 "github.com/luci/luci-go/common/tsmon/store"
14 "github.com/luci/luci-go/common/tsmon/target" 15 "github.com/luci/luci-go/common/tsmon/target"
15 "github.com/luci/luci-go/common/tsmon/types" 16 "github.com/luci/luci-go/common/tsmon/types"
16 "golang.org/x/net/context" 17 "golang.org/x/net/context"
17 18
18 . "github.com/smartystreets/goconvey/convey" 19 . "github.com/smartystreets/goconvey/convey"
19 ) 20 )
20 21
21 func makeContext() context.Context { 22 func makeContext() context.Context {
22 return tsmon.WithState(context.Background(), &tsmon.State{ 23 return tsmon.WithState(context.Background(), &tsmon.State{
23 » » S: store.NewInMemory(&target.Task{ServiceName: " default target"}), 24 » » S: store.NewInMemory(&target.Task{ServiceName: p roto.String("default target")}),
24 M: monitor.NewNilMonitor(), 25 M: monitor.NewNilMonitor(),
25 RegisteredMetrics: map[string]types.Metric{}, 26 RegisteredMetrics: map[string]types.Metric{},
26 }) 27 })
27 } 28 }
28 29
29 func TestMetrics(t *testing.T) { 30 func TestMetrics(t *testing.T) {
30 Convey("Int", t, func() { 31 Convey("Int", t, func() {
31 c := makeContext() 32 c := makeContext()
32 m := NewIntIn(c, "foo", "description") 33 m := NewIntIn(c, "foo", "description")
33 34
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 So(v.Bucketer().GrowthFactor(), ShouldEqual, 0) 227 So(v.Bucketer().GrowthFactor(), ShouldEqual, 0)
227 So(v.Bucketer().Width(), ShouldEqual, 10) 228 So(v.Bucketer().Width(), ShouldEqual, 10)
228 So(v.Bucketer().NumFiniteBuckets(), ShouldEqual, 20) 229 So(v.Bucketer().NumFiniteBuckets(), ShouldEqual, 20)
229 So(v.Sum(), ShouldEqual, 15) 230 So(v.Sum(), ShouldEqual, 15)
230 So(v.Count(), ShouldEqual, 1) 231 So(v.Count(), ShouldEqual, 1)
231 So(err, ShouldBeNil) 232 So(err, ShouldBeNil)
232 233
233 So(func() { NewNonCumulativeDistributionIn(c, "foo", "descriptio n", m.Bucketer()) }, ShouldPanic) 234 So(func() { NewNonCumulativeDistributionIn(c, "foo", "descriptio n", m.Bucketer()) }, ShouldPanic)
234 }) 235 })
235 } 236 }
OLDNEW
« no previous file with comments | « common/tsmon/flush_test.go ('k') | common/tsmon/monitor/acq.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698