| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 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 eventlog |
| 6 |
| 7 import ( |
| 8 "context" |
| 9 "reflect" |
| 10 "testing" |
| 11 "time" |
| 12 |
| 13 "github.com/golang/protobuf/proto" |
| 14 logpb "github.com/luci/luci-go/common/eventlog/proto" |
| 15 ) |
| 16 |
| 17 func TestGeneratesLogEvent(t *testing.T) { |
| 18 c := Client{EventSource: &logpb.InfraEventSource{}} |
| 19 |
| 20 var tNano int64 = 1e9 |
| 21 begin := logpb.ChromeInfraEvent_BEGIN |
| 22 et := TypedTime{ |
| 23 time.Unix(0, tNano), |
| 24 begin, |
| 25 } |
| 26 want := &ChromeInfraLogEvent{ |
| 27 LogEvent: &logpb.LogRequestLite_LogEventLite{ |
| 28 EventTimeMs: proto.Int64(tNano / 1e6), |
| 29 }, |
| 30 InfraEvent: &logpb.ChromeInfraEvent{ |
| 31 TimestampKind: &begin, |
| 32 EventSource: c.EventSource, |
| 33 }, |
| 34 } |
| 35 |
| 36 got := c.NewLogEvent(context.Background(), et) |
| 37 |
| 38 if !reflect.DeepEqual(got, want) { |
| 39 t.Errorf("generated log event: got: %v; want: %v", got, want) |
| 40 } |
| 41 } |
| OLD | NEW |