- Apply B-2 jitter and backoff fixes to Windows service (F-C1-5) Proportional jitter and exponential backoff now in service polling loop - Add known winget install location search for SYSTEM account (F-C1-1) Checks PATH then system-wide WindowsApps locations - Fix winget text parser for package names with spaces (F-C1-2) Column-position parsing from header keywords replaces whitespace split - Add ghost update post-install state verification (F-C1-3) RebootRequired flag on InstallResult marks pending reboot - Replace fmt.Printf with log.Printf in winget scanner (F-C1-6) - Remove emoji from Windows service log messages (F-C1-7) GOOS=linux build: PASS. All tests pass, no regressions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
58 lines
1.8 KiB
Go
58 lines
1.8 KiB
Go
package scanner
|
|
|
|
// winget_logging_test.go — Pre-fix tests for winget logging format.
|
|
// [SHARED] — no build tag, compiles on all platforms.
|
|
//
|
|
// F-C1-6 LOW: Winget scanner uses fmt.Printf not structured logging.
|
|
//
|
|
// Run: cd aggregator-agent && go test ./internal/scanner/... -v -run TestWingetScanner
|
|
|
|
import (
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Test 6.1 — Documents unstructured logging (F-C1-6)
|
|
//
|
|
// Category: PASS-NOW (documents the bug)
|
|
// ---------------------------------------------------------------------------
|
|
|
|
func TestWingetScannerUsesStructuredLogging(t *testing.T) {
|
|
// F-C1-6 LOW: winget scanner uses fmt.Printf for error output.
|
|
// ETHOS #1 requires [TAG] [system] [component] format via log.Printf.
|
|
content, err := os.ReadFile("winget.go")
|
|
if err != nil {
|
|
t.Fatalf("failed to read winget.go: %v", err)
|
|
}
|
|
|
|
src := string(content)
|
|
|
|
if strings.Contains(src, "fmt.Printf") {
|
|
t.Error("[ERROR] [agent] [scanner] F-C1-6 NOT FIXED: fmt.Printf still in winget.go")
|
|
}
|
|
|
|
t.Log("[INFO] [agent] [scanner] F-C1-6 FIXED: fmt.Printf replaced with log.Printf")
|
|
}
|
|
|
|
// ---------------------------------------------------------------------------
|
|
// Test 6.2 — Must have no fmt.Printf (assert fix)
|
|
//
|
|
// Category: FAIL-NOW / PASS-AFTER-FIX
|
|
// ---------------------------------------------------------------------------
|
|
|
|
func TestWingetScannerHasNoFmtPrintf(t *testing.T) {
|
|
content, err := os.ReadFile("winget.go")
|
|
if err != nil {
|
|
t.Fatalf("failed to read winget.go: %v", err)
|
|
}
|
|
|
|
src := string(content)
|
|
|
|
if strings.Contains(src, "fmt.Printf") {
|
|
t.Errorf("[ERROR] [agent] [scanner] winget.go contains fmt.Printf.\n" +
|
|
"F-C1-6: all output must use log.Printf with ETHOS format.")
|
|
}
|
|
}
|