Tests: Add a helper method to reduce sleeping times in test.
This will 'time travel', i.e. change the inserted_at and update_at fields of the object in question. This is used to backdate things were we used sleeping before to ensure time differences.
This commit is contained in:
parent
ba19975838
commit
0ef0aed205
5 changed files with 18 additions and 11 deletions
|
|
@ -55,6 +55,14 @@ defmodule Pleroma.Tests.Helpers do
|
|||
clear_config: 2
|
||||
]
|
||||
|
||||
def time_travel(entity, seconds) do
|
||||
new_time = NaiveDateTime.add(entity.inserted_at, seconds)
|
||||
|
||||
entity
|
||||
|> Ecto.Changeset.change(%{inserted_at: new_time, updated_at: new_time})
|
||||
|> Pleroma.Repo.update()
|
||||
end
|
||||
|
||||
def to_datetime(%NaiveDateTime{} = naive_datetime) do
|
||||
naive_datetime
|
||||
|> DateTime.from_naive!("Etc/UTC")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue