From 16378865457151125248414e887edf62a507abae Mon Sep 17 00:00:00 2001 From: Prithvipal Singh <129885625+ppalsingh@users.noreply.github.com> Date: Mon, 18 Mar 2024 21:37:50 +0530 Subject: [PATCH] [bug] used UTC timezone in testcase (#31798) **Description:** Test case should not use Local timezone, it should use UTC timezone. **Link to tracking Issue:** https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/31797 --- pkg/ottl/ottlfuncs/func_truncate_time_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/ottl/ottlfuncs/func_truncate_time_test.go b/pkg/ottl/ottlfuncs/func_truncate_time_test.go index 33781d3b478eb..626fdd831ea08 100644 --- a/pkg/ottl/ottlfuncs/func_truncate_time_test.go +++ b/pkg/ottl/ottlfuncs/func_truncate_time_test.go @@ -25,7 +25,7 @@ func Test_TruncateTime(t *testing.T) { name: "truncate to 1s", time: &ottl.StandardTimeGetter[any]{ Getter: func(ctx context.Context, tCtx any) (any, error) { - return time.Date(2022, 1, 1, 1, 1, 1, 999999999, time.Local), nil + return time.Date(2022, 1, 1, 1, 1, 1, 999999999, time.UTC), nil }, }, duration: &ottl.StandardDurationGetter[any]{ @@ -34,13 +34,13 @@ func Test_TruncateTime(t *testing.T) { return d, nil }, }, - expected: time.Date(2022, 1, 1, 1, 1, 1, 0, time.Local), + expected: time.Date(2022, 1, 1, 1, 1, 1, 0, time.UTC), }, { name: "truncate to 1ms", time: &ottl.StandardTimeGetter[any]{ Getter: func(ctx context.Context, tCtx any) (any, error) { - return time.Date(2022, 1, 1, 1, 1, 1, 999999999, time.Local), nil + return time.Date(2022, 1, 1, 1, 1, 1, 999999999, time.UTC), nil }, }, duration: &ottl.StandardDurationGetter[any]{ @@ -49,13 +49,13 @@ func Test_TruncateTime(t *testing.T) { return d, nil }, }, - expected: time.Date(2022, 1, 1, 1, 1, 1, 999000000, time.Local), + expected: time.Date(2022, 1, 1, 1, 1, 1, 999000000, time.UTC), }, { name: "truncate old time", time: &ottl.StandardTimeGetter[any]{ Getter: func(ctx context.Context, tCtx any) (any, error) { - return time.Date(1980, 9, 9, 9, 59, 59, 999999999, time.Local), nil + return time.Date(1980, 9, 9, 9, 59, 59, 999999999, time.UTC), nil }, }, duration: &ottl.StandardDurationGetter[any]{ @@ -64,7 +64,7 @@ func Test_TruncateTime(t *testing.T) { return d, nil }, }, - expected: time.Date(1980, 9, 9, 9, 0, 0, 0, time.Local), + expected: time.Date(1980, 9, 9, 9, 0, 0, 0, time.UTC), }, } for _, tt := range tests {