ba0f3 / timecop.nim

Time travelling for Nim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

timecop

nimble install timecop

timecop requires subhook module and not production ready

timecop provides two helpers freezeAt and travelTo template, that will helps you do unittest on specified time

Usage

import times, timecop

freezeAt now():
  # time never changes inside this code block
  echo now()
  sleep(10_000)
  echo now()  

travelTo now() - 1.days:
  # time will starts on yesterday, and continue running
  echo now()
  sleep(10_000)
  echo now()

About

Time travelling for Nim


Languages

Language:Nim 100.0%