Test suite log cleanup 2/3

pull/1186/head
Rick Carlino 2020-04-03 14:04:36 -05:00
parent e8caa769e3
commit 161e97cf0a
2 changed files with 14 additions and 7 deletions

View File

@ -3,6 +3,7 @@ defmodule FarmbotCeleryScript.SchedulerTest do
use Mimic
alias FarmbotCeleryScript.{Scheduler, AST}
alias FarmbotCeleryScript.SysCalls.Stubs
import ExUnit.CaptureLog
setup :set_mimic_global
setup :verify_on_exit!
@ -21,11 +22,14 @@ defmodule FarmbotCeleryScript.SchedulerTest do
|> AST.Factory.read_pin(9, 0)
scheduled_time = DateTime.utc_now() |> DateTime.add(100, :millisecond)
# msg = "[info] Next execution is ready for execution: now"
{:ok, _} = Scheduler.schedule(sch, ast, scheduled_time, %{})
# Hack to force the scheduler to checkup instead of waiting the normal 15 seconds
send(sch, :checkup)
# Sorry.
Process.sleep(1100)
assert capture_log(fn ->
send(sch, :checkup)
# Sorry.
Process.sleep(1100)
end) =~ "[info] Next execution is ready for execution: now"
end
end

View File

@ -98,10 +98,13 @@ defmodule FarmbotCeleryScriptTest do
expect(Stubs, :read_pin, fn _, _ ->
raise("big oops")
end)
io = capture_io(:stderr, fn ->
assert {:error, "big oops"} ==
FarmbotCeleryScript.execute(execute_ast, execute_ast)
end)
io =
capture_io(:stderr, fn ->
assert {:error, "big oops"} ==
FarmbotCeleryScript.execute(execute_ast, execute_ast)
end)
assert io =~ "CeleryScript Exception"
assert_receive {:step_complete, ^execute_ast, {:error, "big oops"}}
end