- mail/go.mod: erstes eigenstaendiges Go-Modul fuer NEXARCH Mail - mail/docs/TESTSTRATEGIE-MAIL.md: Testpyramide (Unit/Integration/ Protokoll-Zustandsmaschinen/E2E/Vertragstests), Pflichttest-Merge-Gate, Bug-Tracking-Konvention (Gitea-Issues), analog Core QA-01 - mail/internal/example: ein reales, kleines Beispiel (Adress- Normalisierung) mit je einem Test pro Testart (Unit/Integration/E2E), 6 Tests real bestanden - mail/internal/pflichttestgate + cmd/pflichttestgate: Merge-Gate-CLI, echter End-zu-Ende-Beweis (Binary lehnt Verstoss ab, akzeptiert begleiteten Test), .gitea/workflows/mail-pflichttest-gate.yml - Ehrlich dokumentiert: kein Gitea-API-Token verfuegbar, daher kein echter Issue angelegt - Bug-Tracking-Vorgehen stattdessen anhand eines realen, bereits dokumentierten Befunds (RET-10) durchgespielt, als offener Punkt vermerkt - Gegenlesen durch zweite Person (Nutzer) noch ausstehend Pruefungen siehe mail/docs/TESTSTRATEGIE-MAIL.md
43 lines
1.2 KiB
Go
43 lines
1.2 KiB
Go
package example
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"github.com/jackc/pgx/v5/pgxpool"
|
|
)
|
|
|
|
// AddressStore ist das Integrationstest-Beispiel (QA-01): eine
|
|
// minimale, aber echte DB-gestützte Komponente — nutzt dieselbe
|
|
// Tenant-DB-Isolationskonvention wie DMS/Archive (t.Cleanup, geteilte
|
|
// physische Postgres-Instanz auf dem Testhost).
|
|
type AddressStore struct {
|
|
pool *pgxpool.Pool
|
|
}
|
|
|
|
func NewAddressStore(pool *pgxpool.Pool) *AddressStore {
|
|
return &AddressStore{pool: pool}
|
|
}
|
|
|
|
func (s *AddressStore) SaveNormalized(ctx context.Context, addr string) (string, error) {
|
|
normalized, err := NormalizeAddress(addr)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
if _, err := s.pool.Exec(ctx, `
|
|
INSERT INTO example_addresses (address) VALUES ($1)
|
|
ON CONFLICT (address) DO NOTHING
|
|
`, normalized); err != nil {
|
|
return "", fmt.Errorf("example: adresse speichern: %w", err)
|
|
}
|
|
return normalized, nil
|
|
}
|
|
|
|
func (s *AddressStore) Exists(ctx context.Context, addr string) (bool, error) {
|
|
var exists bool
|
|
if err := s.pool.QueryRow(ctx, `SELECT EXISTS(SELECT 1 FROM example_addresses WHERE address = $1)`, addr).Scan(&exists); err != nil {
|
|
return false, fmt.Errorf("example: existenz prüfen: %w", err)
|
|
}
|
|
return exists, nil
|
|
}
|