managarten/services/mana-matrix-bot/internal/matrix/markdown_test.go
Till JS 819568c3df feat(infra): consolidate 21 Matrix bots into Go binary + add Go API gateway
Replace 21 separate NestJS Matrix bot processes (~2.1 GB RAM, ~4.2 GB Docker images)
with a single Go binary using plugin architecture (8.6 MB binary, ~30 MB RAM).

New services:
- services/mana-matrix-bot/ — Go Matrix bot with 21 plugins (mautrix-go, Redis sessions)
- services/mana-api-gateway-go/ — Go API gateway (rate limiting, API keys, credit billing)

Deleted:
- 21 services/matrix-*-bot/ directories
- packages/bot-services/ and packages/matrix-bot-common/
- Legacy deploy scripts and CI build jobs

Updated:
- docker-compose.macmini.yml: new Go services, legacy bots removed
- CI/CD: change detection + build jobs for Go services
- Root package.json: new dev:matrix, build:matrix, test:matrix scripts

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-27 21:03:00 +01:00

64 lines
1.5 KiB
Go

package matrix
import "testing"
func TestMarkdownToHTML(t *testing.T) {
tests := []struct {
input string
want string
}{
{"**bold**", "<strong>bold</strong>"},
{"*italic*", "<em>italic</em>"},
{"~~strike~~", "<del>strike</del>"},
{"`code`", "<code>code</code>"},
{"line1\nline2", "line1<br>line2"},
{"**bold** and *italic*", "<strong>bold</strong> and <em>italic</em>"},
{"plain text", "plain text"},
{"", ""},
}
for _, tt := range tests {
got := MarkdownToHTML(tt.input)
if got != tt.want {
t.Errorf("MarkdownToHTML(%q) = %q, want %q", tt.input, got, tt.want)
}
}
}
func TestEscapeHTML(t *testing.T) {
tests := []struct {
input string
want string
}{
{"<script>", "&lt;script&gt;"},
{`"quotes"`, "&quot;quotes&quot;"},
{"a & b", "a &amp; b"},
{"it's", "it&#039;s"},
{"plain", "plain"},
}
for _, tt := range tests {
got := EscapeHTML(tt.input)
if got != tt.want {
t.Errorf("EscapeHTML(%q) = %q, want %q", tt.input, got, tt.want)
}
}
}
func TestFormatNumberedList(t *testing.T) {
items := []string{"Apple", "Banana", "Cherry"}
got := FormatNumberedList(items, func(s string, i int) string { return s })
want := "1. Apple\n2. Banana\n3. Cherry"
if got != want {
t.Errorf("FormatNumberedList = %q, want %q", got, want)
}
}
func TestFormatBulletList(t *testing.T) {
items := []string{"Apple", "Banana"}
got := FormatBulletList(items, func(s string) string { return s })
want := "• Apple\n• Banana"
if got != want {
t.Errorf("FormatBulletList = %q, want %q", got, want)
}
}