nim-dagger/tests/codex/helpers/mockclock.nim

22 lines
452 B
Nim
Raw Normal View History

import std/times
2022-05-19 19:56:03 +00:00
import codex/clock
export clock
type
MockClock* = ref object of Clock
time: SecondsSince1970
func new*(_: type MockClock,
time: SecondsSince1970 = getTime().toUnix): MockClock =
MockClock(time: time)
func set*(clock: MockClock, time: SecondsSince1970) =
clock.time = time
func advance*(clock: MockClock, seconds: int64) =
clock.time += seconds
method now*(clock: MockClock): SecondsSince1970 =
clock.time