Files
Josh Siviour bd14e2d67d refactor: move read-only GetResources aggregation to domains/tagging and retire gateway/tagging (#1209)
* test: characterise current tagging read, write and aggregation behaviour

* docs: record tagging capability discovery and narrowed ADR-0001 cut

* test: update ACM tagging characterisation after key preservation

* feat: add read-only TaggedLister capability in domains/tagging

* feat: add AWSGW tag index and ELBv2 TaggedLister adapters

* refactor: move GetResources aggregation to domains/tagging

* docs: close out the ADR-0001 tagging boundary

* docs: repoint tagging migration citations to the rebased commits
2026-10-15 14:58:44 +10:00

82 lines
2.1 KiB
Go

package layering
import (
"os"
"path/filepath"
"testing"
)
// frozenLegacyPackages is every production package still under a legacy root.
// It only shrinks: a new entry is a new legacy package, a missing one is a
// completed move whose line must be deleted.
var frozenLegacyPackages = []string{
"accountteardown",
"daemon",
"gateway",
"gateway/bedrock",
"gateway/ecs",
"gateway/eks",
"gateway/elbv2",
"gateway/iam",
"gateway/rds",
"gateway/spx",
"gateway/sts",
"handlers/ecs",
"handlers/eks",
"handlers/elbv2",
"handlers/iam",
"handlers/iam/mock",
"handlers/rds",
"handlers/sts",
"lbagent",
}
// retiredLegacyRoots were legacy roots whose every package has moved to its
// ADR-0001 target; recreating one would reopen a closed migration row.
var retiredLegacyRoots = []string{"admin", "services", "utils", "vpcd"}
// TestADR0001_LegacyRootsFrozen: the current-to-target map gives every legacy
// root a destination, so none may gain a package and no retired root may return.
func TestADR0001_LegacyRootsFrozen(t *testing.T) {
root, err := moduleRoot()
if err != nil {
t.Fatal(err)
}
g, err := loadGraph(root)
if err != nil {
t.Fatal(err)
}
present := map[string]bool{}
for name, dir := range g.pkgs {
if c, ok := classify(dir); ok && c.layer == layerLegacy {
present[name] = true
}
}
if len(present) == 0 {
t.Fatal("found no legacy packages; the freeze would pass vacuously")
}
frozen := map[string]bool{}
for _, p := range frozenLegacyPackages {
frozen[p] = true
if !present[p] {
t.Errorf("legacy package %s no longer exists; delete it from frozenLegacyPackages", p)
}
}
for p := range present {
if !frozen[p] {
t.Errorf("ADR-0001 current-to-target map: %s is a new package under a legacy root; create it at its ADR-0001 target home instead", p)
}
}
for _, r := range retiredLegacyRoots {
entries, err := os.ReadDir(filepath.Join(root, "spinifex", r))
if err != nil && !os.IsNotExist(err) {
t.Fatal(err)
}
if len(entries) > 0 {
t.Errorf("ADR-0001 current-to-target map: spinifex/%s is a retired legacy root; give the code its target home instead", r)
}
}
}