diff --git a/test/Spec.hs b/test/Spec.hs index 89f335a..140aa32 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -147,7 +147,6 @@ copyFileSpec = `shouldThrow` (\e -> ioeGetErrorType e == PermissionDenied) - it "copyFile, wrong input type (symlink)" $ copyFile' "test/copyFileSpec/inputFileSymL" "test/copyFileSpec/outputFile" @@ -631,7 +630,7 @@ deleteDirSpec = describe "HSFM.FileSystem.FileOperations.deleteDir" $ do -- successes -- - it "deleteDir, regular file, all fine" $ do + it "deleteDir, empty directory, all fine" $ do createDir'' "test/deleteDirSpec/testDir" deleteDir' "test/deleteDirSpec/testDir" getSymbolicLinkStatus "test/deleteDirSpec/testDir" @@ -642,6 +641,9 @@ deleteDirSpec = createDir'' "test/deleteDirSpec/noPerms/testDir" noPerms "test/deleteDirSpec/noPerms/testDir" deleteDir' "test/deleteDirSpec/noPerms/testDir" + getSymbolicLinkStatus "test/deleteDirSpec/testDir" + `shouldThrow` + (\e -> ioeGetErrorType e == NoSuchThing) -- posix failures -- it "deleteDir, wrong file type (symlink to directory)" $ @@ -654,7 +656,7 @@ deleteDirSpec = `shouldThrow` (\e -> ioeGetErrorType e == InappropriateType) - it "deleteDir, file does not exist" $ + it "deleteDir, directory does not exist" $ deleteDir' "test/deleteDirSpec/doesNotExist" `shouldThrow` (\e -> ioeGetErrorType e == NoSuchThing) @@ -664,7 +666,7 @@ deleteDirSpec = `shouldThrow` (\e -> ioeGetErrorType e == UnsatisfiedConstraints) - it "deleteDir, can't write to parent directory" $ do + it "deleteDir, can't open parent directory" $ do createDir'' "test/deleteDirSpec/noPerms/foo" noPerms "test/deleteDirSpec/noPerms" (deleteDir' "test/deleteDirSpec/noPerms/foo" @@ -673,6 +675,16 @@ deleteDirSpec = >> normalDirPerms "test/deleteDirSpec/noPerms" >> deleteDir' "test/deleteDirSpec/noPerms/foo" + it "deleteDir, can't write to parent directory, still fine" $ do + createDir'' "test/deleteDirSpec/noWritable/foo" + noWritableDirPerms "test/deleteDirSpec/noWritable" + (deleteDir' "test/deleteDirSpec/noWritable/foo" + `shouldThrow` + (\e -> ioeGetErrorType e == PermissionDenied)) + normalDirPerms "test/deleteDirSpec/noWritable" + deleteDir' "test/deleteDirSpec/noWritable/foo" + + deleteDirRecursiveSpec :: Spec deleteDirRecursiveSpec = describe "HSFM.FileSystem.FileOperations.deleteDirRecursive" $ do @@ -740,6 +752,7 @@ deleteDirRecursiveSpec = + ----------------- --[ Utilities ]-- ----------------- @@ -894,8 +907,8 @@ deleteFile' p = do deleteDir' :: ByteString -> IO () deleteDir' p = do pwd <- fromJust <$> getEnv "PWD" >>= P.parseAbs - file <- (pwd P.) <$> P.parseRel p - deleteDir file + dir <- (pwd P.) <$> P.parseRel p + deleteDir dir deleteDirRecursive' :: ByteString -> IO () diff --git a/test/deleteDirSpec/noWritable/.keep b/test/deleteDirSpec/noWritable/.keep new file mode 100644 index 0000000..e69de29