Every alert was titled "brain-capture audit degraded", including the symlink tripwire's and governance-edit alerts. NtfyNotifier.WithTitle returns a titled copy (nil stays nil); buildNotifier(getenv, title) is called per source: capture audit (unchanged title), "brain symlink tripwire", "brain governance edit". Tests assert the Title header. Fixes #163. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
30 lines
1.0 KiB
Go
30 lines
1.0 KiB
Go
package audit
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// hyperguild#163: every alert went out titled "brain-capture audit
|
|
// degraded", including the symlink tripwire's and governance alerts.
|
|
func TestNtfyNotifierSendsItsOwnTitle(t *testing.T) {
|
|
var got []string
|
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
|
got = append(got, r.Header.Get("Title"))
|
|
}))
|
|
defer srv.Close()
|
|
base := NewNtfyNotifier(srv.URL, "")
|
|
require.NoError(t, base.Notify(context.Background(), "m"))
|
|
require.NoError(t, base.WithTitle("brain symlink tripwire").Notify(context.Background(), "m"))
|
|
require.NoError(t, base.Notify(context.Background(), "m"))
|
|
assert.Equal(t, []string{"brain-capture audit degraded", "brain symlink tripwire", "brain-capture audit degraded"}, got,
|
|
"WithTitle returns a copy; the base keeps its default title")
|
|
var nilN *NtfyNotifier
|
|
assert.Nil(t, nilN.WithTitle("x"), "nil (ntfy not configured) stays nil")
|
|
}
|