From 0c63cb608e573ed8dbcc195055df3c28025cc45e Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sat, 9 May 2026 11:31:46 -0500 Subject: [PATCH] test(coverage): exercise PingExecutor run_ping branches via loopback Adds an untagged loopback test (127.0.0.1) so System.cmd / Task.async / Task.yield branches in run_ping/3 are covered in CI runs that exclude :network-tagged tests. --- .../monitoring/executors/ping_executor_test.exs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/towerops/monitoring/executors/ping_executor_test.exs b/test/towerops/monitoring/executors/ping_executor_test.exs index 472ce180..0a620a67 100644 --- a/test/towerops/monitoring/executors/ping_executor_test.exs +++ b/test/towerops/monitoring/executors/ping_executor_test.exs @@ -62,6 +62,16 @@ defmodule Towerops.Monitoring.Executors.PingExecutorTest do assert is_binary(reason) end + test "exercises run_ping path against loopback (no network required)" do + # 127.0.0.1 is always reachable via loopback; this drives the + # System.cmd/Task.async/Task.yield branches that the :network- + # tagged tests cover but which CI excludes by default. + config = %{"host" => "127.0.0.1", "count" => 1} + + result = PingExecutor.execute(config, 2000) + assert match?({:ok, _, _}, result) or match?({:error, _}, result) + end + test "clamps count to range [1, 10]" do # Verified indirectly via build_args: clamp to 10 when given 999 args_high = PingExecutor.build_args("127.0.0.1", 10, 5000)