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") }