now() is not now

now() doesn't change once the transaction begins. This is a pitfall when testing using the Ecto Sandbox since all operations are within a single transaction.

A brief examination of postgresql time and date functions describes that in the notes, but there is another function statement_timestamp() that is what it claims to be, the time of the statement.

If a test creates data, then updates that data and part of the test is to compare the create and modified timestamps, using now() will result in them being equal. An argument might be made to use the Erlang timestamp, but if timestamps for updates are to be believed then they should be all based on the same clock, the one the database runs on.