40 lines
1.2 KiB
Go
40 lines
1.2 KiB
Go
// The Messaging Service reaches the State Store and the workflow engine only
|
|
// through their contracts. Go imports are atomic, so one reference relinks a
|
|
// runtime, and the boundary holds only while something re-measures it.
|
|
|
|
package main
|
|
|
|
import (
|
|
"context"
|
|
"os/exec"
|
|
"strings"
|
|
"testing"
|
|
"time"
|
|
)
|
|
|
|
func TestMessagingDoesNotLinkStoreOrWorkflowRuntime(t *testing.T) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
|
defer cancel()
|
|
out, err := exec.CommandContext(ctx, "go", "list", "-deps", ".").Output()
|
|
if err != nil {
|
|
t.Fatalf("go list -deps .: %v", err)
|
|
}
|
|
linked := map[string]bool{}
|
|
for line := range strings.SplitSeq(strings.TrimSpace(string(out)), "\n") {
|
|
linked[line] = true
|
|
}
|
|
for _, pkg := range []string{
|
|
"github.com/jackc/pgx/v5/pgxpool",
|
|
"github.com/samcharles93/archie-core/internal/infrastructure/postgres",
|
|
"github.com/samcharles93/archie-core/internal/infrastructure/controlplanestore",
|
|
"github.com/samcharles93/archie-core/internal/domain/workflow",
|
|
"github.com/samcharles93/archie-core/internal/agentexec",
|
|
} {
|
|
t.Run(pkg, func(t *testing.T) {
|
|
if linked[pkg] {
|
|
t.Errorf("cmd/archie-messaging links %s: services reach each other only through contracts", pkg)
|
|
}
|
|
})
|
|
}
|
|
}
|