TESTS: improve deleteDirSpec
This commit is contained in:
parent
bd70b8751a
commit
70270d60ba
25
test/Spec.hs
25
test/Spec.hs
@ -147,7 +147,6 @@ copyFileSpec =
|
|||||||
`shouldThrow`
|
`shouldThrow`
|
||||||
(\e -> ioeGetErrorType e == PermissionDenied)
|
(\e -> ioeGetErrorType e == PermissionDenied)
|
||||||
|
|
||||||
|
|
||||||
it "copyFile, wrong input type (symlink)" $
|
it "copyFile, wrong input type (symlink)" $
|
||||||
copyFile' "test/copyFileSpec/inputFileSymL"
|
copyFile' "test/copyFileSpec/inputFileSymL"
|
||||||
"test/copyFileSpec/outputFile"
|
"test/copyFileSpec/outputFile"
|
||||||
@ -631,7 +630,7 @@ deleteDirSpec =
|
|||||||
describe "HSFM.FileSystem.FileOperations.deleteDir" $ do
|
describe "HSFM.FileSystem.FileOperations.deleteDir" $ do
|
||||||
|
|
||||||
-- successes --
|
-- successes --
|
||||||
it "deleteDir, regular file, all fine" $ do
|
it "deleteDir, empty directory, all fine" $ do
|
||||||
createDir'' "test/deleteDirSpec/testDir"
|
createDir'' "test/deleteDirSpec/testDir"
|
||||||
deleteDir' "test/deleteDirSpec/testDir"
|
deleteDir' "test/deleteDirSpec/testDir"
|
||||||
getSymbolicLinkStatus "test/deleteDirSpec/testDir"
|
getSymbolicLinkStatus "test/deleteDirSpec/testDir"
|
||||||
@ -642,6 +641,9 @@ deleteDirSpec =
|
|||||||
createDir'' "test/deleteDirSpec/noPerms/testDir"
|
createDir'' "test/deleteDirSpec/noPerms/testDir"
|
||||||
noPerms "test/deleteDirSpec/noPerms/testDir"
|
noPerms "test/deleteDirSpec/noPerms/testDir"
|
||||||
deleteDir' "test/deleteDirSpec/noPerms/testDir"
|
deleteDir' "test/deleteDirSpec/noPerms/testDir"
|
||||||
|
getSymbolicLinkStatus "test/deleteDirSpec/testDir"
|
||||||
|
`shouldThrow`
|
||||||
|
(\e -> ioeGetErrorType e == NoSuchThing)
|
||||||
|
|
||||||
-- posix failures --
|
-- posix failures --
|
||||||
it "deleteDir, wrong file type (symlink to directory)" $
|
it "deleteDir, wrong file type (symlink to directory)" $
|
||||||
@ -654,7 +656,7 @@ deleteDirSpec =
|
|||||||
`shouldThrow`
|
`shouldThrow`
|
||||||
(\e -> ioeGetErrorType e == InappropriateType)
|
(\e -> ioeGetErrorType e == InappropriateType)
|
||||||
|
|
||||||
it "deleteDir, file does not exist" $
|
it "deleteDir, directory does not exist" $
|
||||||
deleteDir' "test/deleteDirSpec/doesNotExist"
|
deleteDir' "test/deleteDirSpec/doesNotExist"
|
||||||
`shouldThrow`
|
`shouldThrow`
|
||||||
(\e -> ioeGetErrorType e == NoSuchThing)
|
(\e -> ioeGetErrorType e == NoSuchThing)
|
||||||
@ -664,7 +666,7 @@ deleteDirSpec =
|
|||||||
`shouldThrow`
|
`shouldThrow`
|
||||||
(\e -> ioeGetErrorType e == UnsatisfiedConstraints)
|
(\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"
|
createDir'' "test/deleteDirSpec/noPerms/foo"
|
||||||
noPerms "test/deleteDirSpec/noPerms"
|
noPerms "test/deleteDirSpec/noPerms"
|
||||||
(deleteDir' "test/deleteDirSpec/noPerms/foo"
|
(deleteDir' "test/deleteDirSpec/noPerms/foo"
|
||||||
@ -673,6 +675,16 @@ deleteDirSpec =
|
|||||||
>> normalDirPerms "test/deleteDirSpec/noPerms"
|
>> normalDirPerms "test/deleteDirSpec/noPerms"
|
||||||
>> deleteDir' "test/deleteDirSpec/noPerms/foo"
|
>> 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 :: Spec
|
||||||
deleteDirRecursiveSpec =
|
deleteDirRecursiveSpec =
|
||||||
describe "HSFM.FileSystem.FileOperations.deleteDirRecursive" $ do
|
describe "HSFM.FileSystem.FileOperations.deleteDirRecursive" $ do
|
||||||
@ -740,6 +752,7 @@ deleteDirRecursiveSpec =
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
-----------------
|
-----------------
|
||||||
--[ Utilities ]--
|
--[ Utilities ]--
|
||||||
-----------------
|
-----------------
|
||||||
@ -894,8 +907,8 @@ deleteFile' p = do
|
|||||||
deleteDir' :: ByteString -> IO ()
|
deleteDir' :: ByteString -> IO ()
|
||||||
deleteDir' p = do
|
deleteDir' p = do
|
||||||
pwd <- fromJust <$> getEnv "PWD" >>= P.parseAbs
|
pwd <- fromJust <$> getEnv "PWD" >>= P.parseAbs
|
||||||
file <- (pwd P.</>) <$> P.parseRel p
|
dir <- (pwd P.</>) <$> P.parseRel p
|
||||||
deleteDir file
|
deleteDir dir
|
||||||
|
|
||||||
|
|
||||||
deleteDirRecursive' :: ByteString -> IO ()
|
deleteDirRecursive' :: ByteString -> IO ()
|
||||||
|
0
test/deleteDirSpec/noWritable/.keep
Normal file
0
test/deleteDirSpec/noWritable/.keep
Normal file
Loading…
Reference in New Issue
Block a user