Skip to content

Commit

Permalink
Remove mockTime func
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias committed May 8, 2024
1 parent cc961c1 commit 139157f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
9 changes: 1 addition & 8 deletions sdk/metric/internal/aggregate/aggregate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,7 @@ var (
fltrBob = attribute.NewSet(userBob)

// Sat Jan 01 2000 00:00:00 GMT+0000.
staticTime = time.Unix(946684800, 0)
staticNowFunc = func() time.Time { return staticTime }
// Pass to t.Cleanup to override the now function with staticNowFunc and
// revert once the test completes. E.g. t.Cleanup(mockTime(now)).
mockTime = func(orig func() time.Time) (cleanup func()) {
now = staticNowFunc
return func() { now = orig }
}
staticTime = time.Unix(946684800, 0)
)

// y2kPlus returns the timestamp at n seconds past Sat Jan 01 2000 00:00:00 GMT+0000.
Expand Down
4 changes: 3 additions & 1 deletion sdk/metric/internal/aggregate/histogram_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ func TestCumulativeHistogramImutableCounts(t *testing.T) {
}

func TestDeltaHistogramReset(t *testing.T) {
t.Cleanup(mockTime(now))
orig := now
now = func() time.Time { return staticTime }
t.Cleanup(func() {now = orig})

h := newHistogram[int64](bounds, noMinMax, false, 0, dropExemplars[int64])

Expand Down

0 comments on commit 139157f

Please sign in to comment.