aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Verdone <spiral@arcseconds.net>2019-07-24 17:25:11 +0200
committerMike Verdone <spiral@arcseconds.net>2019-07-24 17:25:11 +0200
commit0e2b5a3e6aed7947909c2a1ff1618403546f1572 (patch)
tree5225eb22bd3a5f9c1285616e75c0ed065510e7fa /test
parent2c83eb0b157b2f574f55341e9171f0b5ab7bd3b2 (diff)
downloadpleroma-0e2b5a3e6aed7947909c2a1ff1618403546f1572.tar.gz
WIP
Diffstat (limited to 'test')
-rw-r--r--test/web/mastodon_api/mastodon_api_controller_test.exs18
1 files changed, 11 insertions, 7 deletions
diff --git a/test/web/mastodon_api/mastodon_api_controller_test.exs b/test/web/mastodon_api/mastodon_api_controller_test.exs
index e59908979..fbe0ab375 100644
--- a/test/web/mastodon_api/mastodon_api_controller_test.exs
+++ b/test/web/mastodon_api/mastodon_api_controller_test.exs
@@ -154,23 +154,27 @@ defmodule Pleroma.Web.MastodonAPI.MastodonAPIControllerTest do
refute id == third_id
# An activity that will expire:
- expires_at =
- NaiveDateTime.utc_now()
- |> NaiveDateTime.add(:timer.minutes(120), :millisecond)
- |> NaiveDateTime.truncate(:second)
+ expires_in = 120
conn_four =
conn
|> post("api/v1/statuses", %{
"status" => "oolong",
- "expires_at" => expires_at
+ "expires_in" => expires_in
})
assert fourth_response = %{"id" => fourth_id} = json_response(conn_four, 200)
assert activity = Activity.get_by_id(fourth_id)
assert expiration = ActivityExpiration.get_by_activity_id(fourth_id)
- assert expiration.scheduled_at == expires_at
- assert fourth_response["pleroma"]["expires_at"] == NaiveDateTime.to_iso8601(expires_at)
+
+ estimated_expires_at =
+ NaiveDateTime.utc_now()
+ |> NaiveDateTime.add(:timer.minutes(expires_in), :millisecond)
+ |> NaiveDateTime.truncate(:second)
+
+ # This assert will fail if the test takes longer than a minute. I sure hope it never does:
+ assert abs(NaiveDateTime.diff(expiration.scheduled_at, estimated_expires_at, :second)) < 60
+ assert fourth_response["pleroma"]["expires_at"] == NaiveDateTime.to_iso8601(expiration.scheduled_at)
end
test "replying to a status", %{conn: conn} do