Skip to content

Commit

Permalink
[bug] used UTC timezone in testcase (#31798)
Browse files Browse the repository at this point in the history
**Description:** <Describe what has changed.>
Test case should not use Local timezone, it should use UTC timezone.

**Link to tracking Issue:**
#31797
  • Loading branch information
ppalsingh authored Mar 18, 2024
1 parent 5bf424d commit 1637886
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions pkg/ottl/ottlfuncs/func_truncate_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]{
Expand All @@ -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]{
Expand All @@ -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]{
Expand All @@ -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 {
Expand Down

0 comments on commit 1637886

Please sign in to comment.