Files
felhom.eu/hub/cmd/hub/r600_wiring_test.go
T

35 lines
1.0 KiB
Go

package main
import (
"go/ast"
"go/parser"
"go/token"
"testing"
)
// R-600 seam wiring: main() must hand the WG reconciler's Trigger to the web server, or the customer
// delete cascade's immediate peer push is dead code and the deleted box's peer lingers on the endpoint
// until the next 5-minute tick. RED-PROOF: delete the SetWGPeerSync call → this test fails.
func TestR600_MainWiresWGPeerSyncIntoWeb(t *testing.T) {
f, err := parser.ParseFile(token.NewFileSet(), "main.go", nil, 0)
if err != nil {
t.Fatal(err)
}
wired := false
ast.Inspect(f, func(n ast.Node) bool {
c, ok := n.(*ast.CallExpr)
if !ok {
return true
}
if sel, ok := c.Fun.(*ast.SelectorExpr); ok && sel.Sel.Name == "SetWGPeerSync" && len(c.Args) == 1 {
if arg, ok := c.Args[0].(*ast.SelectorExpr); ok && arg.Sel.Name == "Trigger" {
wired = true
}
}
return true
})
if !wired {
t.Error("cmd/hub/main.go never calls webServer.SetWGPeerSync(<reconciler>.Trigger) — the delete cascade cannot push the peer removal")
}
}