Mailglass.Clock.Frozen (Mailglass v0.1.0)

Copy Markdown View Source

Test helper that freezes Mailglass.Clock.utc_now/0 in the current process. Per-process isolation makes it async: true-safe.

Mailglass.Adapters.Fake.advance_time/1 delegates to advance/1 — one mechanism, not two (D-03 + D-07).

Summary

Functions

Advances the frozen clock by ms milliseconds in the current process.

Freezes the clock at the given DateTime in the current process.

Clears the clock freeze in the current process.

Functions

advance(ms)

(since 0.1.0)
@spec advance(integer()) :: DateTime.t()

Advances the frozen clock by ms milliseconds in the current process.

If no freeze is active, seeds from DateTime.utc_now/0 then adds ms. Returns the new frozen DateTime.

freeze(dt)

(since 0.1.0)
@spec freeze(DateTime.t()) :: DateTime.t()

Freezes the clock at the given DateTime in the current process.

Returns the frozen DateTime. Subsequent calls to Mailglass.Clock.utc_now/0 in this process return the frozen value until unfreeze/0 is called.

unfreeze()

(since 0.1.0)
@spec unfreeze() :: :ok

Clears the clock freeze in the current process.

Returns :ok. Subsequent calls to Mailglass.Clock.utc_now/0 delegate to the configured impl (or Mailglass.Clock.System).