Simplify manual cleaning to directory targets
This commit is contained in:
@@ -116,22 +116,22 @@ func TestCleanRequiresSessionID(t *testing.T) {
|
||||
func TestCleanRejectsUnsafeTargets(t *testing.T) {
|
||||
root := t.TempDir()
|
||||
outside := t.TempDir()
|
||||
if _, err := cleanScopedTarget(root, filepath.Join(outside, "target"), "test.outside", true, false); err == nil {
|
||||
if _, err := cleanScopedTarget(root, filepath.Join(outside, "target"), "test.outside", false); err == nil {
|
||||
t.Fatal("outside target error = nil, want error")
|
||||
}
|
||||
if _, err := cleanScopedTarget(root, root, "test.root", true, false); err == nil {
|
||||
if _, err := cleanScopedTarget(root, root, "test.root", false); err == nil {
|
||||
t.Fatal("root target error = nil, want error")
|
||||
}
|
||||
filePath := filepath.Join(root, "file.txt")
|
||||
mustWriteTestFile(t, filePath, "file")
|
||||
if _, err := cleanScopedTarget(root, filePath, "test.file", true, false); err == nil {
|
||||
if _, err := cleanScopedTarget(root, filePath, "test.file", false); err == nil {
|
||||
t.Fatal("file target error = nil, want error")
|
||||
}
|
||||
symlinkPath := filepath.Join(root, "link")
|
||||
if err := os.Symlink(filepath.Join(root, "missing"), symlinkPath); err != nil {
|
||||
t.Fatalf("Symlink() error = %v", err)
|
||||
}
|
||||
if _, err := cleanScopedTarget(root, symlinkPath, "test.symlink", true, false); err == nil {
|
||||
if _, err := cleanScopedTarget(root, symlinkPath, "test.symlink", false); err == nil {
|
||||
t.Fatal("symlink target error = nil, want error")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user