mirror of
https://github.com/compute-blade-community/compute-blade-agent.git
synced 2026-04-16 15:35:42 +02:00
25 lines
511 B
Go
25 lines
511 B
Go
package util
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/stretchr/testify/mock"
|
|
)
|
|
|
|
// MockClock implements the Clock interface using the testify mock package.
|
|
type MockClock struct {
|
|
mock.Mock
|
|
}
|
|
|
|
// Now returns the current time.
|
|
func (mc *MockClock) Now() time.Time {
|
|
args := mc.Called()
|
|
return args.Get(0).(time.Time)
|
|
}
|
|
|
|
// After waits for the duration to elapse and then sends the current time
|
|
func (mc *MockClock) After(d time.Duration) <-chan time.Time {
|
|
args := mc.Called(d)
|
|
return args.Get(0).(chan time.Time)
|
|
}
|