Test suite log cleanup 2/3
parent
e8caa769e3
commit
161e97cf0a
|
@ -3,6 +3,7 @@ defmodule FarmbotCeleryScript.SchedulerTest do
|
||||||
use Mimic
|
use Mimic
|
||||||
alias FarmbotCeleryScript.{Scheduler, AST}
|
alias FarmbotCeleryScript.{Scheduler, AST}
|
||||||
alias FarmbotCeleryScript.SysCalls.Stubs
|
alias FarmbotCeleryScript.SysCalls.Stubs
|
||||||
|
import ExUnit.CaptureLog
|
||||||
|
|
||||||
setup :set_mimic_global
|
setup :set_mimic_global
|
||||||
setup :verify_on_exit!
|
setup :verify_on_exit!
|
||||||
|
@ -21,11 +22,14 @@ defmodule FarmbotCeleryScript.SchedulerTest do
|
||||||
|> AST.Factory.read_pin(9, 0)
|
|> AST.Factory.read_pin(9, 0)
|
||||||
|
|
||||||
scheduled_time = DateTime.utc_now() |> DateTime.add(100, :millisecond)
|
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, %{})
|
{:ok, _} = Scheduler.schedule(sch, ast, scheduled_time, %{})
|
||||||
|
|
||||||
# Hack to force the scheduler to checkup instead of waiting the normal 15 seconds
|
# Hack to force the scheduler to checkup instead of waiting the normal 15 seconds
|
||||||
send(sch, :checkup)
|
assert capture_log(fn ->
|
||||||
# Sorry.
|
send(sch, :checkup)
|
||||||
Process.sleep(1100)
|
# Sorry.
|
||||||
|
Process.sleep(1100)
|
||||||
|
end) =~ "[info] Next execution is ready for execution: now"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -98,10 +98,13 @@ defmodule FarmbotCeleryScriptTest do
|
||||||
expect(Stubs, :read_pin, fn _, _ ->
|
expect(Stubs, :read_pin, fn _, _ ->
|
||||||
raise("big oops")
|
raise("big oops")
|
||||||
end)
|
end)
|
||||||
io = capture_io(:stderr, fn ->
|
|
||||||
assert {:error, "big oops"} ==
|
io =
|
||||||
FarmbotCeleryScript.execute(execute_ast, execute_ast)
|
capture_io(:stderr, fn ->
|
||||||
end)
|
assert {:error, "big oops"} ==
|
||||||
|
FarmbotCeleryScript.execute(execute_ast, execute_ast)
|
||||||
|
end)
|
||||||
|
|
||||||
assert io =~ "CeleryScript Exception"
|
assert io =~ "CeleryScript Exception"
|
||||||
assert_receive {:step_complete, ^execute_ast, {:error, "big oops"}}
|
assert_receive {:step_complete, ^execute_ast, {:error, "big oops"}}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue