FrozenClock.TestHelpers (FrozenClock v0.1.0)

Copy Markdown View Source

Convenience helpers for using FrozenClock in tests.

import FrozenClock.TestHelpers

test "expires after 1 hour" do
  freeze_time ~U[2026-01-01 00:00:00Z] do
    token = create_token()
    travel(1, :hour)
    assert expired?(token)
  end
end

Summary

Functions

Freezes time at datetime for the duration of the block.

Re-export of FrozenClock.travel/2 so tests only need to import this module.

Functions

freeze_time(datetime, list)

(macro)

Freezes time at datetime for the duration of the block.

Time is always unfrozen afterwards, even if the block raises.

travel(amount, unit)

Re-export of FrozenClock.travel/2 so tests only need to import this module.