aboutsummaryrefslogtreecommitdiff
path: root/test/pleroma
diff options
context:
space:
mode:
authortusooa <tusooa@kazv.moe>2022-08-25 18:38:18 +0000
committertusooa <tusooa@kazv.moe>2022-08-25 18:38:18 +0000
commit6811237ffdc181d40d99649bf8323dbf1b3bb8d9 (patch)
tree15aafa5cb3fe90898934e25515e642c78718021e /test/pleroma
parent6f10f93d625474edb5746fb9580a920c2aa68286 (diff)
parentba31af021ca82c6eb9685e967749620d8b8a44d9 (diff)
downloadpleroma-6811237ffdc181d40d99649bf8323dbf1b3bb8d9.tar.gz
Merge branch 'fix_flaky_transfer_task_test.exs' into 'develop'
Fix flaky/erratic test/pleroma/config/transfer_task_test.exs See merge request pleroma/pleroma!3703
Diffstat (limited to 'test/pleroma')
-rw-r--r--test/pleroma/config/transfer_task_test.exs61
1 files changed, 52 insertions, 9 deletions
diff --git a/test/pleroma/config/transfer_task_test.exs b/test/pleroma/config/transfer_task_test.exs
index 927744add..3dc917362 100644
--- a/test/pleroma/config/transfer_task_test.exs
+++ b/test/pleroma/config/transfer_task_test.exs
@@ -79,35 +79,70 @@ defmodule Pleroma.Config.TransferTaskTest do
describe "pleroma restart" do
setup do
- on_exit(fn -> Restarter.Pleroma.refresh() end)
+ on_exit(fn ->
+ Restarter.Pleroma.refresh()
+
+ # Restarter.Pleroma.refresh/0 is an asynchronous call.
+ # A GenServer will first finish the previous call before starting a new one.
+ # Here we do a synchronous call.
+ # That way we are sure that the previous call has finished before we continue.
+ # See https://stackoverflow.com/questions/51361856/how-to-use-task-await-with-genserver
+ Restarter.Pleroma.rebooted?()
+ end)
end
- @tag :erratic
test "don't restart if no reboot time settings were changed" do
clear_config(:emoji)
insert(:config, key: :emoji, value: [groups: [a: 1, b: 2]])
refute String.contains?(
- capture_log(fn -> TransferTask.start_link([]) end),
+ capture_log(fn ->
+ TransferTask.start_link([])
+
+ # TransferTask.start_link/1 is an asynchronous call.
+ # A GenServer will first finish the previous call before starting a new one.
+ # Here we do a synchronous call.
+ # That way we are sure that the previous call has finished before we continue.
+ Restarter.Pleroma.rebooted?()
+ end),
"pleroma restarted"
)
end
- @tag :erratic
test "on reboot time key" do
clear_config(:shout)
insert(:config, key: :shout, value: [enabled: false])
- assert capture_log(fn -> TransferTask.start_link([]) end) =~ "pleroma restarted"
+
+ # Note that we don't actually restart Pleroma.
+ # See module Restarter.Pleroma
+ assert capture_log(fn ->
+ TransferTask.start_link([])
+
+ # TransferTask.start_link/1 is an asynchronous call.
+ # A GenServer will first finish the previous call before starting a new one.
+ # Here we do a synchronous call.
+ # That way we are sure that the previous call has finished before we continue.
+ Restarter.Pleroma.rebooted?()
+ end) =~ "pleroma restarted"
end
- @tag :erratic
test "on reboot time subkey" do
clear_config(Pleroma.Captcha)
insert(:config, key: Pleroma.Captcha, value: [seconds_valid: 60])
- assert capture_log(fn -> TransferTask.start_link([]) end) =~ "pleroma restarted"
+
+ # Note that we don't actually restart Pleroma.
+ # See module Restarter.Pleroma
+ assert capture_log(fn ->
+ TransferTask.start_link([])
+
+ # TransferTask.start_link/1 is an asynchronous call.
+ # A GenServer will first finish the previous call before starting a new one.
+ # Here we do a synchronous call.
+ # That way we are sure that the previous call has finished before we continue.
+ Restarter.Pleroma.rebooted?()
+ end) =~ "pleroma restarted"
end
- @tag :erratic
test "don't restart pleroma on reboot time key and subkey if there is false flag" do
clear_config(:shout)
clear_config(Pleroma.Captcha)
@@ -116,7 +151,15 @@ defmodule Pleroma.Config.TransferTaskTest do
insert(:config, key: Pleroma.Captcha, value: [seconds_valid: 60])
refute String.contains?(
- capture_log(fn -> TransferTask.load_and_update_env([], false) end),
+ capture_log(fn ->
+ TransferTask.load_and_update_env([], false)
+
+ # TransferTask.start_link/1 is an asynchronous call.
+ # A GenServer will first finish the previous call before starting a new one.
+ # Here we do a synchronous call.
+ # That way we are sure that the previous call has finished before we continue.
+ Restarter.Pleroma.rebooted?()
+ end),
"pleroma restarted"
)
end