From 84a925bc1502e9d0e6b3b74a2c6556d4bcc869db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Kolsj=C3=B6?= Date: Sat, 27 Feb 2016 08:39:17 +0100 Subject: [PATCH] Replace Mix.env checks with capture log in tests This was the original intent (as far as I can see), but I think I had not found capture_log yet when I wrote the code. --- lib/toniq/job_importer.ex | 4 +--- lib/toniq/takeover.ex | 4 +--- test/toniq/failover_test.exs | 1 + test/toniq/job_importer_test.exs | 1 + test/toniq/takeover_test.exs | 1 + 5 files changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/toniq/job_importer.ex b/lib/toniq/job_importer.ex index 284bc20..6a8581c 100644 --- a/lib/toniq/job_importer.ex +++ b/lib/toniq/job_importer.ex @@ -28,9 +28,7 @@ defmodule Toniq.JobImporter do defp log_import([]), do: [] defp log_import(jobs) do - if Mix.env != :test do - Logger.log(:info, "#{__MODULE__}: Importing #{Enum.count(jobs)} jobs from incoming_jobs") - end + Logger.log(:info, "#{__MODULE__}: Importing #{Enum.count(jobs)} jobs from incoming_jobs") jobs end diff --git a/lib/toniq/takeover.ex b/lib/toniq/takeover.ex index d94a9d0..cef7089 100644 --- a/lib/toniq/takeover.ex +++ b/lib/toniq/takeover.ex @@ -40,9 +40,7 @@ defmodule Toniq.Takeover do defp handle_missing_vm(nil, _state), do: nil defp handle_missing_vm(identifier, state) do - if Mix.env != :test do - Logger.log(:info, "#{__MODULE__}: Taking over all jobs from missing vm #{identifier}") - end + Logger.log(:info, "#{__MODULE__}: Taking over all jobs from missing vm #{identifier}") Toniq.KeepalivePersistence.takeover_jobs(identifier, Toniq.Keepalive.identifier(state.keepalive_name)) end diff --git a/test/toniq/failover_test.exs b/test/toniq/failover_test.exs index d2a22d7..a939807 100644 --- a/test/toniq/failover_test.exs +++ b/test/toniq/failover_test.exs @@ -19,6 +19,7 @@ defmodule Toniq.FailoverTest do # leads to unreliable tests). Instead of multiple VMs we simply persist a job as-if # there was another VM (different key names in redis) and then stop the keepalive for # that fake VM and ensure the job is taken over by the test VM. + @tag :capture_log test "orphaned jobs are taken over and run" do Process.register self, :failover_test diff --git a/test/toniq/job_importer_test.exs b/test/toniq/job_importer_test.exs index 354a5c6..f194805 100644 --- a/test/toniq/job_importer_test.exs +++ b/test/toniq/job_importer_test.exs @@ -14,6 +14,7 @@ defmodule Exredis.JobImporterTest do :ok end + @tag :capture_log test "imports jobs from the incoming_jobs queue" do Process.register self, :toniq_job_importer_test Toniq.JobPersistence.store_incoming_job(TestWorker, data: 10) diff --git a/test/toniq/takeover_test.exs b/test/toniq/takeover_test.exs index de26498..2e88ce0 100644 --- a/test/toniq/takeover_test.exs +++ b/test/toniq/takeover_test.exs @@ -13,6 +13,7 @@ defmodule Exredis.TakeoverTest do :ok end + @tag :capture_log test "takes over orphaned jobs" do current_vm = Toniq.Keepalive.identifier other_vm = start_keepalive(:other_vm)