From 161e97cf0a92cbd236afcfe9cfb75478ec6a72ca Mon Sep 17 00:00:00 2001 From: Rick Carlino Date: Fri, 3 Apr 2020 14:04:36 -0500 Subject: [PATCH] Test suite log cleanup 2/3 --- .../test/farmbot_celery_script/scheduler_test.exs | 10 +++++++--- .../test/farmbot_celery_script_test.exs | 11 +++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/farmbot_celery_script/test/farmbot_celery_script/scheduler_test.exs b/farmbot_celery_script/test/farmbot_celery_script/scheduler_test.exs index 81cde7c6..3d5ce6ab 100644 --- a/farmbot_celery_script/test/farmbot_celery_script/scheduler_test.exs +++ b/farmbot_celery_script/test/farmbot_celery_script/scheduler_test.exs @@ -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 diff --git a/farmbot_celery_script/test/farmbot_celery_script_test.exs b/farmbot_celery_script/test/farmbot_celery_script_test.exs index 82301871..c4c7dbd8 100644 --- a/farmbot_celery_script/test/farmbot_celery_script_test.exs +++ b/farmbot_celery_script/test/farmbot_celery_script_test.exs @@ -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