Add ValidateOpsCutover, eventmode CLI, and a host script that pin agent_system_dev and refuse FAV plus test/main before any cluster mode write. Co-authored-by: Cursor <cursoragent@cursor.com>
45 lines
975 B
Go
45 lines
975 B
Go
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
|
|
}
|
|
}
|