From 52d467a9ca7abcf17ab94ad93c6ea4109f6dcbae Mon Sep 17 00:00:00 2001 From: CZ Date: Thu, 19 Sep 2024 20:26:13 +1200 Subject: [PATCH] use time.Unix const --- bridges/otellogr/convert_test.go | 6 ++---- bridges/otellogr/logsink_test.go | 5 ++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/bridges/otellogr/convert_test.go b/bridges/otellogr/convert_test.go index 90018be212a..bec3f4c4405 100644 --- a/bridges/otellogr/convert_test.go +++ b/bridges/otellogr/convert_test.go @@ -80,8 +80,6 @@ func TestConvertKVs(t *testing.T) { } func TestConvertValue(t *testing.T) { - now := time.Now() - for _, tt := range []struct { name string value any @@ -179,8 +177,8 @@ func TestConvertValue(t *testing.T) { }, { name: "time.Time", - value: now, - wantValue: log.Int64Value(now.UnixNano()), + value: time.Unix(1000, 1000), + wantValue: log.Int64Value(time.Unix(1000, 1000).UnixNano()), }, { name: "[]byte", diff --git a/bridges/otellogr/logsink_test.go b/bridges/otellogr/logsink_test.go index 0ff5dd91227..0f8f55af1ea 100644 --- a/bridges/otellogr/logsink_test.go +++ b/bridges/otellogr/logsink_test.go @@ -114,7 +114,6 @@ func TestNewLogSink(t *testing.T) { func TestLogSink(t *testing.T) { const name = "name" - now := time.Now() for _, tt := range []struct { name string @@ -149,7 +148,7 @@ func TestLogSink(t *testing.T) { "float64", 3.14159, "int64", -2, "string", "str", - "time", now, + "time", time.Unix(1000, 1000), "uint64", uint64(3), ) }, @@ -162,7 +161,7 @@ func TestLogSink(t *testing.T) { log.Float64("float64", 3.14159), log.Int64("int64", -2), log.String("string", "str"), - log.Int64("time", now.UnixNano()), + log.Int64("time", time.Unix(1000, 1000).UnixNano()), log.Int64("uint64", 3), }), },