rdev/internal/metrics/metrics_test.go
jordan 72d16929ca feat: Implement hexagonal architecture with services, webhooks, queue, and telemetry
Major refactoring to hexagonal (ports & adapters) architecture:

- Add service layer (apikey_service, project_service) for business logic
- Add webhook system with dispatcher and delivery tracking
- Add command queue with priority-based processing
- Add rate limiting with sliding window algorithm
- Add audit logging for command execution
- Add OpenTelemetry integration (traces, metrics, spans)
- Add circuit breaker for fault tolerance
- Add cached repository wrapper for performance
- Add comprehensive validation package
- Add Kubernetes client integration for pod management
- Add database migrations (allowed_ips, audit_log, rate_limiting, queue, webhooks)
- Add network policy and PodDisruptionBudget for k8s
- Remove legacy executor and projects/registry packages
- Untrack secrets.yaml (now managed via envault)
- Add coverage.out to .gitignore
- Add e2e test infrastructure with docker-compose
- Add comprehensive documentation (API, architecture, operations, plans)
- Add golangci-lint config and pre-commit hook

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-25 19:57:46 -07:00

43 lines
1.3 KiB
Go

package metrics
import "testing"
func TestNormalizePath(t *testing.T) {
tests := []struct {
input string
expected string
}{
// Keys
{"/keys/550e8400-e29b-41d4-a716-446655440000", "/keys/{id}"},
{"/keys", "/keys"},
// Projects
{"/projects/pantheon", "/projects/{id}"},
{"/projects/pantheon/claude", "/projects/{id}/claude"},
{"/projects/aeries/shell", "/projects/{id}/shell"},
{"/projects/test-123/events", "/projects/{id}/events"},
// Claude config
{"/projects/pantheon/claude-config/commands/deploy", "/projects/{id}/claude-config/commands/{name}"},
{"/projects/pantheon/claude-config/skills/go-testing", "/projects/{id}/claude-config/skills/{name}"},
{"/projects/pantheon/claude-config/agents/reviewer", "/projects/{id}/claude-config/agents/{name}"},
{"/projects/pantheon/claude-config/commands", "/projects/{id}/claude-config/commands"},
{"/projects/pantheon/claude-config", "/projects/{id}/claude-config"},
// Unchanged
{"/health", "/health"},
{"/ready", "/ready"},
{"/metrics", "/metrics"},
{"/docs", "/docs"},
}
for _, tt := range tests {
t.Run(tt.input, func(t *testing.T) {
result := normalizePath(tt.input)
if result != tt.expected {
t.Errorf("normalizePath(%q) = %q, want %q", tt.input, result, tt.expected)
}
})
}
}