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>
38 lines
1.1 KiB
Go
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)
|
|
}
|
|
}
|