When writing integration tests that depend on the current date/time, it is very handy to be able to freeze
or travel
to specific moment (like e.g. timecop for ruby)
Is there a way to achieve something similar in Elixir/Erlang?
I tried mocking Erlang built-ins :os.timestamp
, :erlang.universaltime
using meck
library, however it fails with :cannot_mock_builtin
.
In principle I could implement my own utility library than would enable easy mocking of current time and then use it everywhere instead of built-in methods; however, some libraries use built-ins, so this is not a viable option (e.g Ecto.Model.Timestamps
, generating inserted_at
and updated_at
values)