Skip to content

Commit 4c98db8

Browse files
committed
Fix architecture test: add continue after forbidden import match and zero-packages guard
- Add isForbidden flag and continue in forbidden suffix loop to prevent falling through to the allowed-prefix check, which produced a misleading 'add it to allowedPrefixes' error for explicitly forbidden imports. - Add len(agentPkgs)==0 guard to TestAgentPackages_SelfRegister to prevent vacuously passing when no agent packages are discovered.
1 parent 34a1f96 commit 4c98db8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cmd/entire/cli/agent/architecture_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,16 @@ func TestAgentPackages_NoForbiddenImports(t *testing.T) {
8080

8181
// Check forbidden suffixes
8282
rel := strings.TrimPrefix(imp, repoPrefix)
83+
isForbidden := false
8384
for _, forbidden := range forbiddenSuffixes {
8485
if rel == forbidden || strings.HasPrefix(rel, forbidden+"/") {
8586
t.Errorf("forbidden import %q — agent packages must not import %s internals", imp, forbidden)
87+
isForbidden = true
8688
}
8789
}
90+
if isForbidden {
91+
continue
92+
}
8893

8994
// Check it's in the allowed list
9095
allowed := false
@@ -186,6 +191,10 @@ func TestAgentPackages_SelfRegister(t *testing.T) {
186191
agentDir := findAgentDir(t)
187192
agentPkgs := discoverAgentPackages(t, agentDir)
188193

194+
if len(agentPkgs) == 0 {
195+
t.Fatal("no agent packages found — test setup is broken")
196+
}
197+
189198
for _, pkgDir := range agentPkgs {
190199
pkgName := filepath.Base(pkgDir)
191200
t.Run(pkgName, func(t *testing.T) {

0 commit comments

Comments
 (0)