- Rename Go module switchboard-core → armature (155+ files) - Rename Docker image → gobha/armature - Rename K8s resources, secrets, deployments - Rename Prometheus metrics switchboard_* → armature_* - Rename env vars SWITCHBOARD_ADMIN_* → ARMATURE_ADMIN_* - Rename DB names switchboard_core* → armature* - Update all frontend branding, notification templates, docs - Update CI scripts, e2e tests, Keycloak realm, nginx conf - Rename scripts/switchboard-ca.sh → scripts/armature-ca.sh - Rename k8s/switchboard.yaml → k8s/armature.yaml - Rename chart alerting/dashboard files - Fix: DockerHub push uses env: binding for secret injection - Helm chart updated (name, labels, template functions, dashboard, alerting) - Replace favicon/icon assets with Armature brand No functional changes. Pure mechanical rename + CI fix. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
70 lines
1.8 KiB
Go
70 lines
1.8 KiB
Go
package notifications
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
|
|
"armature/models"
|
|
)
|
|
|
|
func TestRenderHTML_Basic(t *testing.T) {
|
|
n := &models.Notification{
|
|
Title: "KB Ready",
|
|
Body: "Your knowledge base has been processed.",
|
|
Type: "kb.ready",
|
|
}
|
|
html := RenderHTML(n, "TestInstance")
|
|
if !strings.Contains(html, "KB Ready") {
|
|
t.Error("expected title in HTML output")
|
|
}
|
|
if !strings.Contains(html, "TestInstance") {
|
|
t.Error("expected instance name in HTML output")
|
|
}
|
|
if !strings.Contains(html, "knowledge base") {
|
|
t.Error("expected body in HTML output")
|
|
}
|
|
}
|
|
|
|
func TestRenderHTML_DefaultInstanceName(t *testing.T) {
|
|
n := &models.Notification{Title: "Test"}
|
|
html := RenderHTML(n, "")
|
|
if !strings.Contains(html, "Armature") {
|
|
t.Error("expected default instance name")
|
|
}
|
|
}
|
|
|
|
func TestRenderText_Basic(t *testing.T) {
|
|
n := &models.Notification{
|
|
Title: "Model Fallback",
|
|
Body: "GPT-4 fell back to GPT-3.5.",
|
|
Type: "role.fallback",
|
|
}
|
|
text := RenderText(n, "MyInstance")
|
|
if !strings.Contains(text, "Model Fallback") {
|
|
t.Error("expected title in text output")
|
|
}
|
|
if !strings.Contains(text, "GPT-4 fell back") {
|
|
t.Error("expected body in text output")
|
|
}
|
|
}
|
|
|
|
func TestSubjectForNotification(t *testing.T) {
|
|
tests := []struct {
|
|
notifType string
|
|
title string
|
|
want string
|
|
}{
|
|
{"kb.ready", "KB Processed", "[Test] Knowledge Base: KB Processed"},
|
|
{"role.fallback", "Fallback", "[Test] Model Alert: Fallback"},
|
|
{"grant.changed", "Added to team", "[Test] Access Change: Added to team"},
|
|
{"custom.type", "Hello", "[Test] Hello"},
|
|
}
|
|
for _, tt := range tests {
|
|
n := &models.Notification{Type: tt.notifType, Title: tt.title}
|
|
got := SubjectForNotification(n, "Test")
|
|
if got != tt.want {
|
|
t.Errorf("SubjectForNotification(%q, %q) = %q, want %q", tt.notifType, tt.title, got, tt.want)
|
|
}
|
|
}
|
|
}
|