internal/apply: a test of the places a module is placed in follows no link on the machine it runs on
Builds: design 47 G A-95 (the owed hang of TestAModulesOwnPlacesAreStillPlaced on real mounts) Claude-Session: https://claude.ai/code/session_01NcbgfGKaxw984XyAPfLm4h
This commit is contained in:
@@ -386,11 +386,15 @@ func below(path, dir string) bool {
|
||||
// atOrBelow says whether path is dir or below it.
|
||||
func atOrBelow(path, dir string) bool { return path == dir || below(path, dir) }
|
||||
|
||||
// evalSymlinks follows the links of an existing path; a variable so a test judges paths whose machine it does not touch (a mount
|
||||
// of the machine it runs on may not answer).
|
||||
var evalSymlinks = filepath.EvalSymlinks
|
||||
|
||||
// resolved is a path with every link in it followed, as far as the path exists, and the rest as declared.
|
||||
func resolved(path string) string {
|
||||
rest := ""
|
||||
for p := path; ; p = filepath.Dir(p) {
|
||||
if real, err := filepath.EvalSymlinks(p); err == nil {
|
||||
if real, err := evalSymlinks(p); err == nil {
|
||||
return filepath.Clean(filepath.Join(real, rest))
|
||||
}
|
||||
if filepath.Dir(p) == p {
|
||||
|
||||
@@ -178,6 +178,11 @@ func TestAFoundDirectoryIsUsedAsFound(t *testing.T) {
|
||||
// The module's own directories keep being placed: below /var/lib, below /etc as root's, a container's mount of
|
||||
// the machine's docker socket.
|
||||
func TestAModulesOwnPlacesAreStillPlaced(t *testing.T) {
|
||||
// The paths below are judged as written: no link of them is followed on the machine the test runs on, whose mounts of them
|
||||
// (a share that does not answer) it does not depend on.
|
||||
was := evalSymlinks
|
||||
evalSymlinks = func(p string) (string, error) { return p, nil }
|
||||
t.Cleanup(func() { evalSymlinks = was })
|
||||
for _, path := range []string{"/var/lib/notes/data", "/etc/systemd/logind.conf.d", "/var/run/fail2ban",
|
||||
"/srv/notes", "/mnt/plex/config", "/storage/media", "/var/lib/mesh/registry"} {
|
||||
if err := refusePath(path, placingDirectory, "notes", ""); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user