X-Git-Url: https://git.squeep.com/?a=blobdiff_plain;f=test%2Fsupport%2Fhelpers.ex;h=4353d5254b84f78f76254d34a0bae849eccdad48;hb=23c6cea889658b5a03b113854f0489ee2da147c7;hp=224034521e683e135f7a354711f43aa23352109d;hpb=31c89acd00396f95a35ea325ed848ffeb2826017;p=akkoma diff --git a/test/support/helpers.ex b/test/support/helpers.ex index 224034521..4353d5254 100644 --- a/test/support/helpers.ex +++ b/test/support/helpers.ex @@ -1,5 +1,5 @@ # Pleroma: A lightweight social networking server -# Copyright © 2017-2020 Pleroma Authors +# Copyright © 2017-2021 Pleroma Authors # SPDX-License-Identifier: AGPL-3.0-only defmodule Pleroma.Tests.Helpers do @@ -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")