Complete forge delivery regression coverage
This commit is contained in:
@@ -226,6 +226,33 @@ func checkImportDirections(packages []listedPackage) error {
|
||||
}
|
||||
visit(modulePath + "/buildinfo")
|
||||
|
||||
for _, root := range []string{
|
||||
modulePath + "/internal/delivery",
|
||||
modulePath + "/internal/forge",
|
||||
modulePath + "/internal/artifact",
|
||||
} {
|
||||
seen := make(map[string]bool)
|
||||
var visitDelivery func(string)
|
||||
visitDelivery = func(path string) {
|
||||
if seen[path] {
|
||||
return
|
||||
}
|
||||
seen[path] = true
|
||||
if path == modulePath+"/internal/gitea" {
|
||||
violations = append(violations, fmt.Sprintf("shared package %s depends on Gitea adapter", root))
|
||||
return
|
||||
}
|
||||
pkg, ok := byPath[path]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
for _, imported := range pkg.Imports {
|
||||
visitDelivery(imported)
|
||||
}
|
||||
}
|
||||
visitDelivery(root)
|
||||
}
|
||||
|
||||
if len(violations) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -162,6 +162,30 @@ func TestRuntimeFacadeCannotDependOnExternalPackages(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSharedDeliveryPackagesCannotDependOnGitea(t *testing.T) {
|
||||
allowed := []listedPackage{
|
||||
{ImportPath: modulePath + "/internal/delivery", Imports: []string{modulePath + "/internal/forge", modulePath + "/internal/artifact"}},
|
||||
{ImportPath: modulePath + "/internal/forge"},
|
||||
{ImportPath: modulePath + "/internal/artifact"},
|
||||
{ImportPath: modulePath + "/internal/gitea"},
|
||||
}
|
||||
if err := checkImportDirections(allowed); err != nil {
|
||||
t.Fatalf("shared delivery boundary rejected neutral dependencies: %v", err)
|
||||
}
|
||||
|
||||
violating := []listedPackage{
|
||||
{ImportPath: modulePath + "/internal/delivery", Imports: []string{modulePath + "/internal/policy"}},
|
||||
{ImportPath: modulePath + "/internal/policy", Imports: []string{modulePath + "/internal/gitea"}},
|
||||
{ImportPath: modulePath + "/internal/forge"},
|
||||
{ImportPath: modulePath + "/internal/artifact"},
|
||||
{ImportPath: modulePath + "/internal/gitea"},
|
||||
}
|
||||
err := checkImportDirections(violating)
|
||||
if err == nil || !strings.Contains(err.Error(), "shared package "+modulePath+"/internal/delivery depends on Gitea adapter") {
|
||||
t.Fatalf("checkImportDirections() error = %v, want transitive shared-delivery violation", err)
|
||||
}
|
||||
}
|
||||
|
||||
func checkFixture(t *testing.T, facadeSource string) []string {
|
||||
t.Helper()
|
||||
fset := token.NewFileSet()
|
||||
|
||||
Reference in New Issue
Block a user