mirror of
https://github.com/Dvorinka/Primora.git
synced 2026-10-28 15:51:23 +00:00
HA scheduler: the job scheduler and alert evaluator hold session-scoped PostgreSQL advisory locks on pinned pool connections — replicas scan for due work exactly once, failover verified live with two replicas. Manual and hook-triggered runs stay available on any replica. Email surface: mailer renders registered templates (invitation); every send is logged to core.email_log with status and error text. New GET /projects/:id/emails endpoint; Members page shows an Email log card. Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package services
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestRenderMailTemplateInvitation(t *testing.T) {
|
|
subject, body, err := renderMailTemplate("invitation", map[string]string{
|
|
"organization": "Acme Corp",
|
|
"invite_url": "https://app.primora.dev/accept?token=abc",
|
|
})
|
|
if err != nil {
|
|
t.Fatalf("render: %v", err)
|
|
}
|
|
if !strings.Contains(subject, "Acme Corp") {
|
|
t.Fatalf("subject missing organization: %q", subject)
|
|
}
|
|
if !strings.Contains(body, "https://app.primora.dev/accept?token=abc") {
|
|
t.Fatalf("body missing invite url: %q", body)
|
|
}
|
|
}
|
|
|
|
func TestRenderMailTemplateUnknown(t *testing.T) {
|
|
if _, _, err := renderMailTemplate("does-not-exist", nil); err == nil {
|
|
t.Fatal("expected error for unknown template")
|
|
}
|
|
}
|
|
|
|
func TestExtractEmail(t *testing.T) {
|
|
if got := extractEmail("Primora <[email protected]>"); got != "[email protected]" {
|
|
t.Fatalf("extractEmail = %q", got)
|
|
}
|
|
if got := extractEmail("[email protected]"); got != "[email protected]" {
|
|
t.Fatalf("extractEmail bare = %q", got)
|
|
}
|
|
}
|