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.
This commit is contained in:
Graham McIntire 2026-05-09 11:31:46 -05:00
parent efd18facb1
commit 0c63cb608e

View file

@ -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)