Phase 7: daily summary and read-only Hub API (AUD-73)
- internal/hub: project side of the frozen ask-contract. GET /capabilities, read-only POST /ask answerer (no LLM, <3s), and the outbound POST /notify client. - internal/apprise: daily-summary delivery through the house Apprise API. - internal/summary: deterministic plain-text daily summary builder. - internal/store: CountByCategory, MessagesByCategory, and summary CRUD. - internal/server: /capabilities and /ask (bearer-token protected), plus the Reports screen (/reports, build, send, delete). - main.go: -summary, -summary-send, and -notify CLI entry points for n8n. Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -109,3 +109,55 @@ func TestLoadInvalidEnv(t *testing.T) {
|
||||
t.Fatal("Load() error = nil, want error for invalid env")
|
||||
}
|
||||
}
|
||||
|
||||
func TestHubAndAppriseConfig(t *testing.T) {
|
||||
for _, k := range []string{"HUB_TOKEN", "HUB_BASE_URL", "APPRISE_URL", "APPRISE_KEY", "APPRISE_URLS", "EMAIL_AGENT_SUMMARY_TO", "HUB_NOTIFY_TIMEOUT"} {
|
||||
t.Setenv(k, "")
|
||||
}
|
||||
cfg, err := Load()
|
||||
if err != nil {
|
||||
t.Fatalf("Load() error = %v", err)
|
||||
}
|
||||
if cfg.HubConfigured() {
|
||||
t.Error("HubConfigured() = true with no HUB_TOKEN")
|
||||
}
|
||||
if cfg.HubBaseURL != DefaultHubBaseURL {
|
||||
t.Errorf("HubBaseURL = %q, want %q", cfg.HubBaseURL, DefaultHubBaseURL)
|
||||
}
|
||||
if cfg.AppriseURL != DefaultAppriseURL {
|
||||
t.Errorf("AppriseURL = %q, want %q", cfg.AppriseURL, DefaultAppriseURL)
|
||||
}
|
||||
if cfg.SummaryTo != DefaultSummaryTo {
|
||||
t.Errorf("SummaryTo = %q, want %q", cfg.SummaryTo, DefaultSummaryTo)
|
||||
}
|
||||
if cfg.AppriseConfigured() {
|
||||
t.Error("AppriseConfigured() = true with no key or URLs")
|
||||
}
|
||||
|
||||
t.Setenv("HUB_TOKEN", "hub-secret")
|
||||
t.Setenv("APPRISE_KEY", "email-summary")
|
||||
cfg, err = Load()
|
||||
if err != nil {
|
||||
t.Fatalf("Load() error = %v", err)
|
||||
}
|
||||
if !cfg.HubConfigured() {
|
||||
t.Error("HubConfigured() = false with HUB_TOKEN set")
|
||||
}
|
||||
if !cfg.AppriseConfigured() {
|
||||
t.Error("AppriseConfigured() = false with a key set")
|
||||
}
|
||||
|
||||
// A stateless URL list also configures Apprise.
|
||||
t.Setenv("APPRISE_KEY", "")
|
||||
t.Setenv("APPRISE_URLS", "mailto://a:b@example.com, ntfy://topic")
|
||||
cfg, err = Load()
|
||||
if err != nil {
|
||||
t.Fatalf("Load() error = %v", err)
|
||||
}
|
||||
if !cfg.AppriseConfigured() {
|
||||
t.Error("AppriseConfigured() = false with APPRISE_URLS set")
|
||||
}
|
||||
if len(cfg.AppriseURLs) != 2 {
|
||||
t.Errorf("AppriseURLs = %v, want 2 entries", cfg.AppriseURLs)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user