package stacks import "testing" // TestIsUserdataDir pins which namespace-relative dirs the migrate merge-walk routes through the // 2775-setgid re-assert (EnsureUserdataDir) vs plain source-mode preservation. This is the M3 routing // decision: only the customer-facing `userdata` tree gets the convention ENFORCED on pre-existing target // dirs. // // COMPANION GUARD: the pre-fix merge-walk had NO userdata branch (everything went through // preserveDirOwnership, which copies the SOURCE mode) — equivalent to isUserdataDir always returning // false. The `userdata/...` → true cases below fail that impl, so a stale 755 target userdata dir would // keep its 755 instead of becoming 2775. func TestIsUserdataDir(t *testing.T) { yes := []string{"userdata", "userdata/import", "userdata/import/calibre", "userdata/media/movies"} no := []string{"appdata", "appdata/romm", "backups", "media", "userdataX", "", "."} for _, r := range yes { if !isUserdataDir(r) { t.Errorf("isUserdataDir(%q) = false, want true", r) } } for _, r := range no { if isUserdataDir(r) { t.Errorf("isUserdataDir(%q) = true, want false (only the userdata tree gets the setgid re-assert)", r) } } }