44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
package admin
|
|
|
|
import (
|
|
"go/ast"
|
|
"go/parser"
|
|
"go/token"
|
|
"strconv"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestAdminApplicationHasNoProxyDetailOrRedisExtractionDependency(t *testing.T) {
|
|
t.Parallel()
|
|
packages, err := parser.ParseDir(token.NewFileSet(), ".", nil, parser.ImportsOnly)
|
|
if err != nil {
|
|
t.Fatalf("ParseDir(): %v", err)
|
|
}
|
|
for _, parsedPackage := range packages {
|
|
for filename, file := range parsedPackage.Files {
|
|
ast.Inspect(file, func(node ast.Node) bool {
|
|
importSpec, ok := node.(*ast.ImportSpec)
|
|
if !ok {
|
|
return true
|
|
}
|
|
path, err := strconv.Unquote(importSpec.Path.Value)
|
|
if err != nil {
|
|
t.Errorf("unquote import in %s: %v", filename, err)
|
|
return false
|
|
}
|
|
for _, forbidden := range []string{
|
|
"internal/adapters/redisactivity",
|
|
"internal/domain/activitypool",
|
|
"internal/domain/extraction",
|
|
} {
|
|
if strings.Contains(path, forbidden) {
|
|
t.Errorf("%s imports forbidden data-plane package %q", filename, path)
|
|
}
|
|
}
|
|
return false
|
|
})
|
|
}
|
|
}
|
|
}
|