Durable notify/advance/projection are live on shared dev, so composition roots must not assign OnOutbox or AddOnApprovedHook. Bind helpers remain for tests and a rollback window. Co-authored-by: Cursor <cursoragent@cursor.com>
49 lines
992 B
Go
49 lines
992 B
Go
package app
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestProductionCompositionHasNoHookRegistration(t *testing.T) {
|
|
root := findGoMod(t)
|
|
files := []string{
|
|
filepath.Join(root, "internal", "app", "app.go"),
|
|
filepath.Join(root, "internal", "server", "workflow_approval_hook.go"),
|
|
filepath.Join(root, "internal", "server", "server.go"),
|
|
}
|
|
for _, f := range files {
|
|
b, err := os.ReadFile(f)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
src := string(b)
|
|
if strings.Contains(src, "OnOutbox =") {
|
|
t.Fatalf("%s still assigns OnOutbox", f)
|
|
}
|
|
if strings.Contains(src, "AddOnApprovedHook(") {
|
|
t.Fatalf("%s still registers AddOnApprovedHook", f)
|
|
}
|
|
}
|
|
}
|
|
|
|
func findGoMod(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
|
|
}
|
|
}
|