All checks were successful
release-tag / release-image (push) Successful in 2m6s
56 lines
1.8 KiB
Go
56 lines
1.8 KiB
Go
package app
|
|
|
|
import (
|
|
"bytes"
|
|
"testing"
|
|
)
|
|
|
|
func TestPDFHeader(t *testing.T) {
|
|
end := int64(3_600_000)
|
|
pdf := makePDF([]Entry{{ID: "x", Client: "ACME", Activity: "Arbeit", StartMS: 0, EndMS: &end}}, Settings{RoundingMinutes: 1, TimeFormat: "24", Timezone: "UTC"}, User{DisplayName: "Test"}, false)
|
|
if !bytes.HasPrefix(pdf, []byte("%PDF-1.4")) {
|
|
t.Fatal("missing PDF header")
|
|
}
|
|
if !bytes.Contains(pdf, []byte("xref")) {
|
|
t.Fatal("missing xref")
|
|
}
|
|
}
|
|
|
|
func TestCSVCompactOmitsActivity(t *testing.T) {
|
|
end := int64(3_600_000)
|
|
b, err := makeCSV([]Entry{{ID: "x", Client: "ACME", Activity: "Geheim", StartMS: 0, EndMS: &end}}, Settings{RoundingMinutes: 1, TimeFormat: "24", Timezone: "UTC"}, true)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if bytes.Contains(b, []byte("Geheim")) {
|
|
t.Fatal("compact CSV contains activity")
|
|
}
|
|
}
|
|
|
|
func TestServiceReportPDFContainsSignatureFields(t *testing.T) {
|
|
end := int64(3_600_000)
|
|
pdf := makeServiceReportPDF(
|
|
[]Entry{{ID: "x", Client: "ACME", Activity: "Router geprüft und Firmware aktualisiert", StartMS: 0, EndMS: &end}},
|
|
Settings{RoundingMinutes: 1, TimeFormat: "24", Timezone: "UTC"},
|
|
User{DisplayName: "Max Techniker", Username: "max"},
|
|
serviceReportMeta{Client: "ACME", Contact: "Erika Kunde", OrderNumber: "SR-42", ReportDate: "14.08.2026"},
|
|
)
|
|
for _, want := range [][]byte{[]byte("%PDF-1.4"), []byte("SERVICE-BERICHT"), []byte("ACME"), []byte("Gesamtdauer"), []byte("Unterschrift Kunde"), []byte("Unterschrift Techniker")} {
|
|
if !bytes.Contains(pdf, want) {
|
|
t.Fatalf("service report missing %q", want)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestWrapPDFText(t *testing.T) {
|
|
lines := wrapPDFText("eins zwei drei vier", 9)
|
|
if len(lines) < 2 {
|
|
t.Fatalf("expected wrapped lines, got %#v", lines)
|
|
}
|
|
for _, line := range lines {
|
|
if len([]rune(line)) > 9 {
|
|
t.Fatalf("line too long: %q", line)
|
|
}
|
|
}
|
|
}
|