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

Unified Diff: common/eventlog/eventlog_test.go

Issue 2517503002: luci-go: Basic support for event logging in Go. (Closed)
Patch Set: Add helpers for generating TypedTime Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « common/eventlog/eventlog.go ('k') | common/eventlog/internal/logservice/logservice.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: common/eventlog/eventlog_test.go
diff --git a/common/eventlog/eventlog_test.go b/common/eventlog/eventlog_test.go
new file mode 100644
index 0000000000000000000000000000000000000000..a28a210cb78ef3e5f4778dd61166a3b8ee3e72f5
--- /dev/null
+++ b/common/eventlog/eventlog_test.go
@@ -0,0 +1,41 @@
+// Copyright 2016 The LUCI Authors. All rights reserved.
+// Use of this source code is governed under the Apache License, Version 2.0
+// that can be found in the LICENSE file.
+
+package eventlog
+
+import (
+ "context"
+ "reflect"
+ "testing"
+ "time"
+
+ "github.com/golang/protobuf/proto"
+ logpb "github.com/luci/luci-go/common/eventlog/proto"
+)
+
+func TestGeneratesLogEvent(t *testing.T) {
+ c := Client{EventSource: &logpb.InfraEventSource{}}
+
+ var tNano int64 = 1e9
+ begin := logpb.ChromeInfraEvent_BEGIN
+ et := TypedTime{
+ time.Unix(0, tNano),
+ begin,
+ }
+ want := &ChromeInfraLogEvent{
+ LogEvent: &logpb.LogRequestLite_LogEventLite{
+ EventTimeMs: proto.Int64(tNano / 1e6),
+ },
+ InfraEvent: &logpb.ChromeInfraEvent{
+ TimestampKind: &begin,
+ EventSource: c.EventSource,
+ },
+ }
+
+ got := c.NewLogEvent(context.Background(), et)
+
+ if !reflect.DeepEqual(got, want) {
+ t.Errorf("generated log event: got: %v; want: %v", got, want)
+ }
+}
« no previous file with comments | « common/eventlog/eventlog.go ('k') | common/eventlog/internal/logservice/logservice.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698