@@ -696,3 +696,68 @@ func TestCallMicroflowUnknownResultTypeStillDeclaresVariable(t *testing.T) {
696696 t .Fatal ("expected Result to remain declared after unresolved call return type" )
697697 }
698698}
699+
700+ func TestValidateMicroflowReferencesSkipsExcludedMicroflow (t * testing.T ) {
701+ moduleID := model .ID ("module-1" )
702+ backend := & mock.MockBackend {
703+ IsConnectedFunc : func () bool { return true },
704+ ListModulesFunc : func () ([]* model.Module , error ) {
705+ return []* model.Module {{
706+ BaseElement : model.BaseElement {ID : moduleID },
707+ Name : "SyntheticAudit" ,
708+ }}, nil
709+ },
710+ ListMicroflowsFunc : func () ([]* microflows.Microflow , error ) {
711+ return nil , nil
712+ },
713+ }
714+ ctx , _ := newMockCtx (t , withBackend (backend ))
715+
716+ stmt := & ast.CreateMicroflowStmt {
717+ Excluded : true ,
718+ Name : ast.QualifiedName {Module : "SyntheticAudit" , Name : "ExcludedLegacyFlow" },
719+ Body : []ast.MicroflowStatement {
720+ & ast.CallMicroflowStmt {
721+ MicroflowName : ast.QualifiedName {Module : "SyntheticAudit" , Name : "DeletedScaffoldFlow" },
722+ },
723+ },
724+ }
725+
726+ if err := validate (ctx , stmt ); err != nil {
727+ t .Fatalf ("excluded microflow reference validation returned error: %v" , err )
728+ }
729+ }
730+
731+ func TestValidateMicroflowReferencesReportsIncludedMissingMicroflow (t * testing.T ) {
732+ moduleID := model .ID ("module-1" )
733+ backend := & mock.MockBackend {
734+ IsConnectedFunc : func () bool { return true },
735+ ListModulesFunc : func () ([]* model.Module , error ) {
736+ return []* model.Module {{
737+ BaseElement : model.BaseElement {ID : moduleID },
738+ Name : "SyntheticAudit" ,
739+ }}, nil
740+ },
741+ ListMicroflowsFunc : func () ([]* microflows.Microflow , error ) {
742+ return nil , nil
743+ },
744+ }
745+ ctx , _ := newMockCtx (t , withBackend (backend ))
746+
747+ stmt := & ast.CreateMicroflowStmt {
748+ Name : ast.QualifiedName {Module : "SyntheticAudit" , Name : "IncludedFlow" },
749+ Body : []ast.MicroflowStatement {
750+ & ast.CallMicroflowStmt {
751+ MicroflowName : ast.QualifiedName {Module : "SyntheticAudit" , Name : "DeletedScaffoldFlow" },
752+ },
753+ },
754+ }
755+
756+ err := validate (ctx , stmt )
757+ if err == nil {
758+ t .Fatal ("expected missing microflow reference error" )
759+ }
760+ if ! strings .Contains (err .Error (), "microflow not found: SyntheticAudit.DeletedScaffoldFlow" ) {
761+ t .Fatalf ("unexpected validation error: %v" , err )
762+ }
763+ }
0 commit comments