Files
Redflag/aggregator-server/internal/database/queries/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

52 lines
1.4 KiB
Go

package queries_test
// ethos_logging_test.go — Pre-fix tests for fmt.Printf used as logging.
// D-2: Database query files use fmt.Printf for warnings and cleanup.
import (
"os"
"strings"
"testing"
)
func TestQueriesUseFmtPrintfForLogging(t *testing.T) {
// D-2: Database query files use fmt.Printf for warning and cleanup
// messages. These should use log.Printf with ETHOS format.
files := []string{"docker.go", "metrics.go", "updates.go"}
total := 0
for _, f := range files {
content, err := os.ReadFile(f)
if err != nil {
t.Logf("[WARNING] [server] [database] could not read %s: %v", f, err)
continue
}
count := strings.Count(string(content), "fmt.Printf")
count += strings.Count(string(content), "fmt.Println")
total += count
}
if total == 0 {
t.Error("[ERROR] [server] [database] D-2 already fixed: no fmt.Printf in query files")
}
t.Logf("[INFO] [server] [database] D-2 confirmed: %d fmt.Printf calls across query files", total)
}
func TestQueriesUseStructuredLogging(t *testing.T) {
files := []string{"docker.go", "metrics.go", "updates.go"}
for _, f := range files {
content, err := os.ReadFile(f)
if err != nil {
continue
}
count := strings.Count(string(content), "fmt.Printf")
count += strings.Count(string(content), "fmt.Println")
if count > 0 {
t.Errorf("[ERROR] [server] [database] %d fmt.Printf calls in %s.\n"+
"D-2: use log.Printf with [TAG] [server] [database] format.", count, f)
}
}
}