Blame test/Data/Conduit/Process/TypedSpec.hs
|
Packit |
4b2029 |
module Data.Conduit.Process.TypedSpec (spec) where
|
|
Packit |
4b2029 |
|
|
Packit |
4b2029 |
import Test.Hspec
|
|
Packit |
4b2029 |
import Data.Conduit
|
|
Packit |
4b2029 |
import Data.Conduit.Process.Typed
|
|
Packit |
4b2029 |
import qualified Data.Conduit.List as CL
|
|
Packit |
4b2029 |
import qualified Data.ByteString as B
|
|
Packit |
4b2029 |
|
|
Packit |
4b2029 |
spec :: Spec
|
|
Packit |
4b2029 |
spec = do
|
|
Packit |
4b2029 |
it "cat works" $ do
|
|
Packit |
4b2029 |
let fp = "ChangeLog.md"
|
|
Packit |
4b2029 |
pc = setStdout createSource $ proc "cat" [fp]
|
|
Packit |
4b2029 |
bs <- B.readFile fp
|
|
Packit |
4b2029 |
bss <- withProcess_ pc $ \p -> runConduit $ getStdout p .| CL.consume
|
|
Packit |
4b2029 |
B.concat bss `shouldBe` bs
|
|
Packit |
4b2029 |
it "cat works with withLoggedProcess_" $ do
|
|
Packit |
4b2029 |
let fp = "ChangeLog.md"
|
|
Packit |
4b2029 |
pc = proc "cat" [fp]
|
|
Packit |
4b2029 |
bs <- B.readFile fp
|
|
Packit |
4b2029 |
bss <- withLoggedProcess_ pc $ \p -> runConduit $ getStdout p .| CL.consume
|
|
Packit |
4b2029 |
B.concat bss `shouldBe` bs
|
|
Packit |
4b2029 |
it "failing process throws" $ do
|
|
Packit |
4b2029 |
(withLoggedProcess_ (proc "cat" ["does not exist"]) $ \p -> do
|
|
Packit |
4b2029 |
runConduit $ getStdout p .| CL.mapM_ (error "shouldn't have data"))
|
|
Packit |
4b2029 |
`shouldThrow` anyException
|
|
Packit |
4b2029 |
it "failing process throws" $ do
|
|
Packit |
4b2029 |
(withProcess_ (proc "cat" ["does not exist"]) $ const $ return ())
|
|
Packit |
4b2029 |
`shouldThrow` anyException
|