Files
trivy/pkg/clock/clock.go
2022-05-26 21:34:15 +03:00

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()
}