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

Side by Side Diff: common/logging/cloudlog/logging_test.go

Issue 2937693003: Make luci-go compile again after deps.lock roll. (Closed)
Patch Set: Created 3 years, 6 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/logging/cloudlog/logging.go ('k') | grpc/cmd/cproto/testdata/helloworld/test.pb.golden » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file.
4
5 package cloudlog
6
7 import (
8 "testing"
9 "time"
10
11 "github.com/luci/luci-go/common/clock/testclock"
12 "github.com/luci/luci-go/common/cloudlogging"
13 "github.com/luci/luci-go/common/logging"
14 . "github.com/smartystreets/goconvey/convey"
15 "golang.org/x/net/context"
16 )
17
18 type testClient struct {
19 logC chan []*cloudlogging.Entry
20 err error
21 }
22
23 func (c *testClient) PushEntries(entries []*cloudlogging.Entry) error {
24 c.logC <- entries
25 return c.err
26 }
27
28 func TestCloudLogging(t *testing.T) {
29 Convey(`A cloud logging instance using a test client`, t, func() {
30 now := time.Date(2015, 1, 1, 0, 0, 0, 0, time.UTC)
31 ctx, _ := testclock.UseTime(context.Background(), now)
32
33 client := &testClient{
34 logC: make(chan []*cloudlogging.Entry, 1),
35 }
36
37 config := Config{
38 InsertIDBase: "totally-random",
39 }
40
41 ctx = Use(ctx, config, client)
42
43 Convey(`Can publish logging data.`, func() {
44 logging.Fields{
45 "foo": "bar",
46 }.Infof(ctx, "Message at %s", "INFO")
47
48 entries := <-client.logC
49 So(len(entries), ShouldEqual, 1)
50 So(entries[0], ShouldResemble, &cloudlogging.Entry{
51 InsertID: "totally-random.0.0",
52 Timestamp: now,
53 Severity: cloudlogging.Info,
54 Labels: cloudlogging.Labels{
55 "foo": "bar",
56 },
57 TextPayload: `Message at INFO {"foo":"bar"}`,
58 })
59 })
60 })
61 }
OLDNEW
« no previous file with comments | « common/logging/cloudlog/logging.go ('k') | grpc/cmd/cproto/testdata/helloworld/test.pb.golden » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698