RemoveRecursive used Stat on the root, so deleting a remote symlink to a directory walked into the target and deleted its contents. The root is now examined with Lstat (links are removed with Remove), and Walk also Lstats its root. Ports the analysts' TestRemoveRecursiveSymlinkToDir onto the sshtest server. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
757 B
Go
28 lines
757 B
Go
package remote
|
|
|
|
import (
|
|
"os"
|
|
"testing"
|
|
|
|
"vcom/internal/testutil/sshtest"
|
|
)
|
|
|
|
// setup starts an in-process SSH server (serving the real filesystem),
|
|
// connects an SSHClient to it with an isolated HOME and returns the client
|
|
// and a scratch directory.
|
|
func setup(t *testing.T) (*sshtest.Server, *SSHClient, string) {
|
|
t.Helper()
|
|
sshtest.IsolatedHome(t)
|
|
srv := sshtest.Start(t, sshtest.Options{})
|
|
c, err := Connect(SSHHost{Name: "test", HostName: "127.0.0.1", Port: srv.Port(), User: "u", Password: srv.Password})
|
|
if err != nil {
|
|
t.Fatalf("connect: %v", err)
|
|
}
|
|
t.Cleanup(func() { c.Close() })
|
|
return srv, c, t.TempDir()
|
|
}
|
|
|
|
func writeFile(t *testing.T, p string, size int, mode os.FileMode) {
|
|
t.Helper()
|
|
sshtest.WriteRandom(t, p, size, mode)
|
|
}
|