test: LeaderElection cluster status aggregation

This commit is contained in:
Graham McIntire 2026-04-24 08:25:36 -05:00
parent b2d4403f14
commit 3887712d23
No known key found for this signature in database
GPG key ID: F4ABF488E6029E59

View file

@ -341,6 +341,26 @@ defmodule Aprsme.Cluster.LeaderElectionTest do
end
end
describe "get_cluster_aprs_status/0 clustered mode" do
setup do
original = Application.get_env(:aprsme, :cluster_enabled)
on_exit(fn -> Application.put_env(:aprsme, :cluster_enabled, original || false) end)
:ok
end
test "clustered mode aggregates local status with cluster_info" do
Application.put_env(:aprsme, :cluster_enabled, true)
status = LeaderElection.get_cluster_aprs_status()
assert is_map(status)
# In clustered mode, cluster_info is added.
if Map.has_key?(status, :cluster_info) do
assert is_map(status.cluster_info)
assert Map.has_key?(status.cluster_info, :total_nodes)
assert Map.has_key?(status.cluster_info, :connected_nodes)
end
end
end
describe "handle_info(:check_cluster_and_elect) direct callback" do
test "no-ops when election already forced" do
state = %LeaderElection{