Files
felhom-controller/controller/internal/appbackup/userdata_test.go
T
admin 8fadbd9891 v0.172.0 fixup 2: drop import/* from the carry-list
Found on the demo-hp live leg: with import, import/paperless and import/calibre
in the carry-list, the derived skeleton RE-CREATES a per-drive drop-zone on every
drive forever — the dead lookalike the canonical root exists to remove, and one
that is never backed up (class: excluded).

Not a zero-removals violation: nothing deletes what an existing box has. Both
demo boxes' old drop-zones were verified to hold zero files before the change.
2026-07-26 08:22:13 +02:00

64 lines
2.3 KiB
Go

package appbackup
import (
"os"
"path/filepath"
"testing"
)
// TestSharedContentGID pins the shared content group to 1000 (FileBrowser's gid + the apps' PUID/PGID).
func TestSharedContentGID(t *testing.T) {
if SharedContentGID != 1000 {
t.Errorf("SharedContentGID = %d, want 1000", SharedContentGID)
}
}
// TestUserdataSkeleton_List asserts the locked carry-list. R-75 renamed the hardcoded list to
// UserdataSkeletonCarry (it is now the non-derived carry-list) and DELIBERATELY dropped the three
// `import*` entries: carrying them would re-create a per-drive drop-zone on every drive forever, the
// dead lookalike the canonical root exists to remove. That is not a removal — nothing deletes the
// dirs an existing box has; they stop being maintained and stop appearing on fresh boxes. Every other
// entry is unchanged, which is the zero-removals promise.
func TestUserdataSkeleton_List(t *testing.T) {
got := map[string]bool{}
for _, s := range UserdataSkeletonCarry() {
got[s] = true
}
for _, want := range []string{
"media/movies", "media/tv", "media/music", "media/audiobooks", "media/books",
"media/comics", "media/photos", "downloads",
"roms", "documents",
} {
if !got[want] {
t.Errorf("skeleton missing %q", want)
}
}
for _, gone := range []string{"import", "import/paperless", "import/calibre"} {
if got[gone] {
t.Errorf("carry-list must NOT hold %q — the drop-zone is canonical on the system drive (R-75)", gone)
}
}
}
// TestUserdataDir confirms the userdata root is a sibling under the namespace.
func TestUserdataDir(t *testing.T) {
if got := UserdataDir("/mnt/felhom-usb"); got != filepath.Clean("/mnt/felhom-usb/userdata") {
t.Errorf("UserdataDir = %q", got)
}
}
// TestEnsureUserdataSkeleton_Structure: every skeleton dir is created (chown may fail off-root, which
// is ignored — dirs + setgid still land). Runs cross-platform.
func TestEnsureUserdataSkeleton_Structure(t *testing.T) {
ns := t.TempDir()
dirs := BuildUserdataSkeleton(nil) // no catalog derived → the carry-list floor
_ = EnsureUserdataSkeleton(ns, dirs) // ignore chown error on a non-root CI host
base := UserdataDir(ns)
for _, sub := range append([]string{""}, dirs...) {
p := filepath.Join(base, sub)
if fi, err := os.Stat(p); err != nil || !fi.IsDir() {
t.Errorf("skeleton dir missing: %s (%v)", p, err)
}
}
}