File: FilesystemSpec.hs

package info (click to toggle)
haskell-conduit-extra 1.3.8-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 288 kB
  • sloc: haskell: 2,601; makefile: 3
file content (38 lines) | stat: -rw-r--r-- 1,425 bytes parent folder | download | duplicates (4)
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