Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Commit

Permalink
Replace Mix.env checks with capture log in tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
joakimk committed Feb 27, 2016
1 parent 473a886 commit 84a925b
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
4 changes: 1 addition & 3 deletions lib/toniq/job_importer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions lib/toniq/takeover.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/toniq/failover_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions test/toniq/job_importer_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions test/toniq/takeover_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 84a925b

Please sign in to comment.