Files
archie/internal/channels/manager_test.go
T
sam 472d8d717c feat(config,channels): format-neutral config resolution and truthful channel state
Loader.Resolve() selects TOML/YAML files or a config directory as the
production entry point, replacing the TOML-only Overlay() as the default
path. Add internal/channels.Manager, reporting each adapter's actual
runtime lifecycle (configured/starting/running/degraded/failed) instead of
inferring health from configuration presence alone. Wire channel reload
through a per-adapter seam.

Fixes #55
2026-08-09 01:25:58 +10:00

26 lines
774 B
Go

package channels
import "testing"
func TestManagerTracksConfiguredLifecycleAndReloadCapability(t *testing.T) {
m := NewManager([]Descriptor{
{ID: "telegram", Name: "Telegram", Configured: true, ReloadSupported: true},
{ID: "email", Name: "Email", Configured: false},
})
if got := m.Snapshot()[0].State; got != StateConfigured {
t.Fatalf("initial state = %q, want %q", got, StateConfigured)
}
m.MarkStarting("telegram")
m.MarkRunning("telegram")
m.MarkFailed("telegram", "token rejected")
views := m.Snapshot()
if got := views[0]; got.State != StateFailed || got.Detail != "token rejected" || !got.ReloadSupported {
t.Errorf("telegram = %#v", got)
}
if got := views[1]; got.State != StateStopped || got.Configured {
t.Errorf("email = %#v", got)
}
}