Refactoring: cmd/kver + internal-Pakete statt package main
Aufteilung nach Zuständigkeit (httpapi, account, linkpreview, charts, impression, media, database, apperr), Abhängigkeiten per Konstruktor statt globalem Zustand, Worker mit Context-gesteuertem Lebenszyklus. Lange Funktionen aufgeteilt, ignorierte Fehler behandelt bzw. geloggt, Schema als schema.sql eingebettet. Logs jetzt strukturiert (slog) ohne Client-IP und Query-String. Tests laufen parallel mit eigenem Schema je Test; neue Tests für account, media und apperr. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TiXsPUqw7oeomZ8wZrQW5q
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
abc2d9b72b
commit
ddeca63ae9
@@ -0,0 +1,49 @@
|
||||
package apperr
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestModifiersCopy(t *testing.T) {
|
||||
t.Parallel()
|
||||
sentinel := NotFound("x.missing", "Fehlt.")
|
||||
cause := errors.New("ursache")
|
||||
tests := []struct {
|
||||
name string
|
||||
err *Error
|
||||
}{
|
||||
{"At", sentinel.At("feld")},
|
||||
{"WithFields", sentinel.WithFields(map[string]string{"a": "b"})},
|
||||
{"WithCause", sentinel.WithCause(cause)},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if sentinel.Field != "" || sentinel.Fields != nil || sentinel.Unwrap() != nil {
|
||||
t.Fatalf("%s hat das Sentinel verändert: %+v", tt.name, sentinel)
|
||||
}
|
||||
if !errors.Is(fmt.Errorf("verpackt: %w", tt.err), sentinel) {
|
||||
t.Errorf("%s: Kopie gilt nicht mehr als das Sentinel", tt.name)
|
||||
}
|
||||
}
|
||||
if !errors.Is(sentinel.WithCause(cause), cause) {
|
||||
t.Error("Ursache nicht über errors.Is erreichbar")
|
||||
}
|
||||
}
|
||||
|
||||
func TestFrom(t *testing.T) {
|
||||
t.Parallel()
|
||||
tests := []struct {
|
||||
err error
|
||||
want Kind
|
||||
}{
|
||||
{Invalid("a.b", "x"), KindInvalid},
|
||||
{fmt.Errorf("verpackt: %w", Conflict("a.c", "x")), KindConflict},
|
||||
{errors.New("roh"), KindInternal},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
if got := From(tt.err).Kind; got != tt.want {
|
||||
t.Errorf("From(%v).Kind = %v, erwartet %v", tt.err, got, tt.want)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user