Web Variante in Go V0.1

This commit is contained in:
concierge committed 2026-11-12 20:00:33 +01:00
1 parent f9e3e94629
commit 692b9b6ef8
60 files changed
+13140

No files matched your search

+56
View File
@@ -0,0 +1,56 @@
package pdf
import (
"bytes"
"testing"
"time"
"lektorenplan/domain"
)
func sampleRows() (domain.DayRange, []domain.DayPlanRow, []domain.Church, []domain.Person) {
church := domain.Church{ID: "c1", Name: "St. Andreas", ShortName: "Andreas",
Symbol: domain.SymbolBasilica, ColorHex: "#9B5B44", Address: "Andreasstraße 1", SortIndex: 0}
person := domain.Person{ID: "p1", FirstName: "Anna", LastName: "Berg",
Roles: []domain.Role{domain.RoleLector}, Active: true}
service := domain.ServiceOccurrence{
ID: "s1", ChurchID: "c1", Date: domain.MustDate("2026-11-15"),
TimeMinutes: 9*60 + 30, Title: "Hochamt", LectorsNeeded: 1, HelpersNeeded: 2,
Kind: domain.KindRegular, CreatedAt: time.Now(),
}
assignment := domain.Assignment{ID: "a1", ServiceID: "s1", PersonID: "p1", Role: domain.RoleLector}
liturgy := domain.LiturgicalDay{
Date: domain.MustDate("2026-11-15"), Title: "33. Sonntag im Jahreskreis",
Rank: domain.RankSolemnity, Color: domain.ColorGreen,
Readings: domain.Readings{First: "Mal 3, 19-20a", Gospel: "Lk 21, 5-19"},
IsObligation: true, Source: "test",
}
row := domain.DayPlanRow{
Date: domain.MustDate("2026-11-15"), LiturgicalDay: &liturgy,
Services: []domain.ServiceWithAssignments{{Service: service, Church: church, Assignments: []domain.Assignment{assignment}}},
}
r := domain.NewDayRange(domain.MustDate("2026-11-15"), domain.MustDate("2026-11-15"))
return r, []domain.DayPlanRow{row}, []domain.Church{church}, []domain.Person{person}
}
func TestFullPlan(t *testing.T) {
r, rows, churches, people := sampleRows()
var buf bytes.Buffer
if err := FullPlan(&buf, r, rows, churches, people, Options{TenantName: "Bad Godesberg"}); err != nil {
t.Fatalf("render: %v", err)
}
if buf.Len() < 1000 || !bytes.HasPrefix(buf.Bytes(), []byte("%PDF")) {
t.Fatalf("unexpected PDF output (%d bytes)", buf.Len())
}
}
func TestCompactPlan(t *testing.T) {
r, rows, _, people := sampleRows()
var buf bytes.Buffer
if err := CompactPlan(&buf, r, rows, people, Options{TenantName: "Bad Godesberg"}); err != nil {
t.Fatalf("render: %v", err)
}
if buf.Len() < 1000 || !bytes.HasPrefix(buf.Bytes(), []byte("%PDF")) {
t.Fatalf("unexpected PDF output (%d bytes)", buf.Len())
}
}