Files
Redflag/aggregator-server/internal/services/ethos_logging_test.go
jpetree331 0da761243b test(ethos): D-2 pre-fix tests for ETHOS compliance violations
Pre-fix tests documenting emoji in log statements and fmt.Printf
used as logging across server and agent codebases.

Tests added:
- Server emoji: machine_binding.go, agents.go, update handlers (6 tests)
- Server fmt.Printf: queries, handlers, services (6 tests)
- Agent emoji: main.go log paths, migration executor (4 tests)
- Exemptions: display/terminal.go, setup.go (2 tests, always pass)

Current state: 8 FAIL, 8 PASS, 2 ALWAYS-PASS.
All prior tests pass. No regressions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-29 10:14:01 -04:00

38 lines
1.1 KiB
Go

package services_test
// ethos_logging_test.go — Pre-fix tests for fmt.Printf in services.
// D-2: security_settings_service.go uses fmt.Printf for audit log warning.
import (
"os"
"strings"
"testing"
)
func TestServicesUseFmtPrintfForLogging(t *testing.T) {
content, err := os.ReadFile("security_settings_service.go")
if err != nil {
t.Fatalf("failed to read security_settings_service.go: %v", err)
}
count := strings.Count(string(content), "fmt.Printf")
if count == 0 {
t.Error("[ERROR] [server] [services] D-2 already fixed: no fmt.Printf in security_settings_service.go")
}
t.Logf("[INFO] [server] [services] D-2 confirmed: %d fmt.Printf calls in security_settings_service.go", count)
}
func TestServicesUseStructuredLogging(t *testing.T) {
content, err := os.ReadFile("security_settings_service.go")
if err != nil {
t.Fatalf("failed to read security_settings_service.go: %v", err)
}
count := strings.Count(string(content), "fmt.Printf")
if count > 0 {
t.Errorf("[ERROR] [server] [services] %d fmt.Printf calls in security_settings_service.go.\n"+
"D-2: use log.Printf with ETHOS format.", count)
}
}