package httpapi import "testing" // TestEffectiveNodeStatus guards the "don't show a node healthy when its agent is // offline" fix: a DB-'up' node with an offline agent must report "down". func TestEffectiveNodeStatus(t *testing.T) { cases := []struct { name string db string online bool want string }{ {"up + agent online", "up", true, "up"}, {"up + agent offline → down", "up", false, "down"}, // the core fix {"draining untouched when offline", "draining", false, "draining"}, {"down stays down", "down", true, "down"}, } for _, c := range cases { t.Run(c.name, func(t *testing.T) { if got := effectiveNodeStatus(c.db, c.online); got != c.want { t.Errorf("effectiveNodeStatus(%q, %v) = %q, want %q", c.db, c.online, got, c.want) } }) } }