ZDDC/zddc/internal/zddc/special_test.go
ZDDC 1e0e403f1e feat(zddc): retire defaults.zddc.yaml; .zddc.zip is the policy carrier (phase 6)
Completes the migration. The embedded per-depth tree (internal/zddc/defaults/)
is now the sole source of the shipped baseline; defaults.zddc.yaml is deleted.

  - EmbeddedDefaults() assembles the tree (no yaml). show-defaults now emits a
    .zddc.zip (per-depth, "*" wildcard members) via EmbeddedDefaultsZip() —
    operators redirect it to <ROOT>/.zddc.zip (or any directory) and edit/add/
    delete individual members.
  - Dropped EmbeddedDefaultsBytes; reworked the dumpable test to validate the
    emitted zip; removed the now-redundant tree-vs-yaml oracle (the Layer-2
    matrix is the ongoing behavioral guarantee, and it stays green).
  - Swept stale "defaults.zddc.yaml" comment references to the embedded tree.
  - GRAMMAR.md §1/§6 updated: .zddc.zip is a policy bundle mountable at ANY
    directory (subtree mount; inherit:false + acl.inherit:false = island); the
    shipped baseline is the embedded bundle at the root.

Net of the 6-phase migration: policy is per-depth .zddc files in a .zddc.zip
that an operator can drop at any level to override the cascade; the engine
(Assemble + the unchanged walker) enforces it. Full Go suite + matrix green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-05 11:35:21 -05:00

61 lines
2 KiB
Go

package zddc
import (
"os"
"path/filepath"
"testing"
)
// TestIsAutoOwnPath / TestIsWormPath / TestWormFolderLevelIndex /
// TestWormMaskStripsWDA retired in the cascade-config migration. The
// `auto_own:` and `worm:` .zddc keys carry these conventions now —
// see lookups_test.go (AutoOwnAt) and worm_test.go (WormZoneGrant);
// the canonical defaults live in internal/zddc/defaults/.
func TestResolveCanonicalCaseFold(t *testing.T) {
dir := t.TempDir()
if err := os.MkdirAll(filepath.Join(dir, "Working"), 0o755); err != nil {
t.Fatal(err)
}
if err := os.MkdirAll(filepath.Join(dir, "ARCHIVE"), 0o755); err != nil {
t.Fatal(err)
}
// A regular file with a canonical name must NOT be returned (we only resolve directories).
if err := os.WriteFile(filepath.Join(dir, "staging"), []byte{}, 0o644); err != nil {
t.Fatal(err)
}
cases := map[string]string{
"working": "Working", // PascalCase wins because it exists on disk
"WORKING": "Working",
"Working": "Working",
"archive": "ARCHIVE",
"reviewing": "", // not present
"staging": "", // present as a file, not a directory — must skip
}
for logical, want := range cases {
got, err := ResolveCanonical(dir, logical)
if err != nil {
t.Errorf("ResolveCanonical(%q): %v", logical, err)
continue
}
if got != want {
t.Errorf("ResolveCanonical(%q) = %q, want %q", logical, got, want)
}
}
}
func TestResolveCanonicalMissingParent(t *testing.T) {
got, err := ResolveCanonical(filepath.Join(t.TempDir(), "does-not-exist"), "working")
if err != nil {
t.Errorf("expected nil error for missing parent, got %v", err)
}
if got != "" {
t.Errorf("expected empty result for missing parent, got %q", got)
}
}
// TestCanonicalLists and TestIsProjectRootFolder retired in Phase 3 —
// the canonical convention is now expressed in internal/zddc/defaults/ and
// asserted by lookups_test.go (TestDefaultToolAt_FromEmbeddedConvention,
// TestIsDeclaredPath_FromEmbeddedConvention, etc.).