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

Side by Side Diff: appengine/tsmon/global_callback_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 | « no previous file | appengine/tsmon/middleware.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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 tsmon 5 package tsmon
6 6
7 import ( 7 import (
8 "net/http" 8 "net/http"
9 "net/http/httptest" 9 "net/http/httptest"
10 "testing" 10 "testing"
11 "time" 11 "time"
12 12
13 "github.com/golang/protobuf/proto"
13 "github.com/julienschmidt/httprouter" 14 "github.com/julienschmidt/httprouter"
14 "github.com/luci/gae/service/datastore" 15 "github.com/luci/gae/service/datastore"
15 "github.com/luci/luci-go/common/clock/testclock" 16 "github.com/luci/luci-go/common/clock/testclock"
16 "github.com/luci/luci-go/common/tsmon" 17 "github.com/luci/luci-go/common/tsmon"
17 "github.com/luci/luci-go/common/tsmon/metric" 18 "github.com/luci/luci-go/common/tsmon/metric"
18 "github.com/luci/luci-go/common/tsmon/monitor" 19 "github.com/luci/luci-go/common/tsmon/monitor"
19 "github.com/luci/luci-go/common/tsmon/store" 20 "github.com/luci/luci-go/common/tsmon/store"
20 "github.com/luci/luci-go/common/tsmon/target" 21 "github.com/luci/luci-go/common/tsmon/target"
21 "golang.org/x/net/context" 22 "golang.org/x/net/context"
22 23
(...skipping 21 matching lines...) Expand all
44 c := context.Background() 45 c := context.Background()
45 46
46 Convey("Register callback without metrics panics", t, func() { 47 Convey("Register callback without metrics panics", t, func() {
47 So(func() { 48 So(func() {
48 RegisterGlobalCallbackIn(c, func(context.Context) {}) 49 RegisterGlobalCallbackIn(c, func(context.Context) {})
49 }, ShouldPanic) 50 }, ShouldPanic)
50 }) 51 })
51 52
52 Convey("Global callbacks", t, func() { 53 Convey("Global callbacks", t, func() {
53 c, clock := buildGAETestContext() 54 c, clock := buildGAETestContext()
54 » » s := store.NewInMemory(&target.Task{ServiceName: "default target "}) 55 » » s := store.NewInMemory(&target.Task{ServiceName: proto.String("d efault target")})
55 mon := &monitor.Fake{} 56 mon := &monitor.Fake{}
56 state := tsmon.GetState(c) 57 state := tsmon.GetState(c)
57 state.S = s 58 state.S = s
58 state.M = mon 59 state.M = mon
59 m := metric.NewCallbackStringIn(c, "foo", "") 60 m := metric.NewCallbackStringIn(c, "foo", "")
60 61
61 RegisterGlobalCallbackIn(c, func(c context.Context) { 62 RegisterGlobalCallbackIn(c, func(c context.Context) {
62 m.Set(c, "bar") 63 m.Set(c, "bar")
63 }, m) 64 }, m)
64 65
(...skipping 20 matching lines...) Expand all
85 So(err, ShouldBeNil) 86 So(err, ShouldBeNil)
86 So(val, ShouldBeNil) 87 So(val, ShouldBeNil)
87 88
88 So(len(mon.Cells), ShouldEqual, 1) 89 So(len(mon.Cells), ShouldEqual, 1)
89 So(len(mon.Cells[0]), ShouldEqual, 1) 90 So(len(mon.Cells[0]), ShouldEqual, 1)
90 So(mon.Cells[0][0].Value, ShouldEqual, "bar") 91 So(mon.Cells[0][0].Value, ShouldEqual, "bar")
91 }) 92 })
92 }) 93 })
93 }) 94 })
94 } 95 }
OLDNEW
« no previous file with comments | « no previous file | appengine/tsmon/middleware.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698