package scheduler import ( "go/ast" "go/parser" "go/token" "testing" ) func TestScheduledCycleDoesNotPersistArticlesThroughRegistryRunAll(t *testing.T) { fset := token.NewFileSet() file, err := parser.ParseFile(fset, "scheduler.go", nil, 0) if err != nil { t.Fatal(err) } for _, declaration := range file.Decls { function, ok := declaration.(*ast.FuncDecl) if !ok || function.Name.Name != "run" { continue } ast.Inspect(function.Body, func(node ast.Node) bool { call, ok := node.(*ast.CallExpr) if !ok { return true } selector, ok := call.Fun.(*ast.SelectorExpr) if ok && selector.Sel.Name == "RunAll" { t.Errorf("scheduled generation still invokes Registry.RunAll at %s", fset.Position(call.Pos())) } return true }) } }