Files
tenant-registry/internal/server/trialoffers_internal_test.go
T
sharangandClaude Opus 5.5 60f20e6419
ci / shared (push) Successful in 13s
ci / test (push) Successful in 23m58s
ci / image (push) Successful in 36s
feat(trial): legal trial signup: offer, confirmation, activation (#58)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
2026-09-30 16:00:52 +00:00

50 lines
1.5 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package server
import (
"testing"
"time"
)
func TestSlugFromCompany(t *testing.T) {
for in, want := range map[string]string{
"Müller Maschinenbau GmbH": "mueller-maschinenbau",
"Müller Maschinenbau GmbH & Co. KG": "mueller-maschinenbau",
"Straßenbau Süd AG": "strassenbau-sued",
"Élan Systèmes SARL": "elan-systemes",
"ACME": "acme",
"X GmbH": "x-firma",
"GmbH": "gmbh",
"Die sehr lange Firmenbezeichnung für Maschinen und Anlagenbau GmbH": "die-sehr-lange-firmenbezeichnung-fuer",
"123 Industries Ltd.": "123-industries",
} {
if got := slugFromCompany(in); got != want {
t.Errorf("%q → %q, want %q", in, got, want)
}
if got := slugFromCompany(in); len(got) > 40 || !slugRE.MatchString(got) {
t.Errorf("%q → %q is not a valid slug", in, got)
}
}
}
func TestTrialEndIsFourteenCalendarDaysInBerlin(t *testing.T) {
// across the switch to winter time (25.10.2026): 14 calendar days, same
// clock time in Berlin, so 14×24h + 1h
start := time.Date(2026, 10, 20, 8, 30, 0, 0, time.UTC) // 10:30 CEST
end := trialEnd(start)
if got := end.In(erpZone).Format("02.01.2006 15:04"); got != "03.11.2026 10:30" {
t.Fatalf("end %s", got)
}
if d := end.Sub(start); d != 14*24*time.Hour+time.Hour {
t.Fatalf("duration %v", d)
}
}
func TestGermanDate(t *testing.T) {
if got := germanDate("2026-10-01"); got != "1. Oktober 2026" {
t.Fatal(got)
}
if got := germanDate("bad"); got != "bad" {
t.Fatal(got)
}
}