1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
module Data.Conduit.FilesystemSpec (spec) where
import Test.Hspec
import Data.Conduit
import qualified Data.Conduit.List as CL
import Data.Conduit.Filesystem
import Data.List (sort, isSuffixOf)
import System.FilePath ((</>))
spec :: Spec
spec = describe "Data.Conduit.Filesystem" $ do
it "sourceDirectory" $ do
res <- runConduitRes
$ sourceDirectory ("test" </> "filesystem")
.| CL.filter (not . (".swp" `isSuffixOf`))
.| CL.consume
sort res `shouldBe`
[ "test" </> "filesystem" </> "bar.txt"
, "test" </> "filesystem" </> "baz.txt"
, "test" </> "filesystem" </> "bin"
, "test" </> "filesystem" </> "foo.txt"
]
it "sourceDirectoryDeep" $ do
res1 <- runConduitRes
$ sourceDirectoryDeep False ("test" </> "filesystem")
.| CL.filter (not . (".swp" `isSuffixOf`))
.| CL.consume
res2 <- runConduitRes
$ sourceDirectoryDeep True ("test" </> "filesystem")
.| CL.filter (not . (".swp" `isSuffixOf`))
.| CL.consume
sort res1 `shouldBe`
[ "test" </> "filesystem" </> "bar.txt"
, "test" </> "filesystem" </> "baz.txt"
, "test" </> "filesystem" </> "bin" </> "bin.txt"
, "test" </> "filesystem" </> "foo.txt"
]
sort res1 `shouldBe` sort res2
|