package events_test import ( "os" "path/filepath" "strings" "testing" ) func TestEventConsumerModeScriptGates(t *testing.T) { root := repoRoot(t) text, err := os.ReadFile(filepath.Join(root, "scripts", "event-consumer-mode.sh")) if err != nil { t.Fatal(err) } s := string(text) if !strings.Contains(s, "fav") || !strings.Contains(s, "refusing test/main") { t.Fatal("script must reject fav and test/main") } if strings.Contains(s, "5434") || strings.Contains(s, "5435") { t.Fatal("script must not pin test/main ports") } if !strings.Contains(s, "agent_system_dev") || !strings.Contains(s, "5433") { t.Fatal("script must pin shared dev db") } } func repoRoot(t *testing.T) string { t.Helper() dir, err := os.Getwd() if err != nil { t.Fatal(err) } for { if _, err := os.Stat(filepath.Join(dir, "go.mod")); err == nil { return dir } parent := filepath.Dir(dir) if parent == dir { t.Fatal("go.mod not found") } dir = parent } }