mirror of
https://github.com/aquasecurity/trivy.git
synced 2025-12-21 14:50:53 -08:00
Co-authored-by: Shira Cohen <97398476+ShiraCohen33@users.noreply.github.com> Co-authored-by: knqyf263 <knqyf263@gmail.com>
24 lines
382 B
Go
24 lines
382 B
Go
package clock
|
|
|
|
import (
|
|
"testing"
|
|
"time"
|
|
|
|
"k8s.io/utils/clock"
|
|
clocktesting "k8s.io/utils/clock/testing"
|
|
)
|
|
|
|
var c clock.Clock = clock.RealClock{}
|
|
|
|
// SetFakeTime sets a fake time for testing.
|
|
func SetFakeTime(t *testing.T, fakeTime time.Time) {
|
|
c = clocktesting.NewFakeClock(fakeTime)
|
|
t.Cleanup(func() {
|
|
c = clock.RealClock{}
|
|
})
|
|
}
|
|
|
|
func Now() time.Time {
|
|
return c.Now()
|
|
}
|