This commit is contained in:
Julian Ospald 2020-01-29 21:02:45 +01:00
parent 126f23659e
commit d30896b4d6
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
2 changed files with 61 additions and 0 deletions

View File

@ -33,6 +33,28 @@ library
default-language: Haskell2010
GHC-Options: -Wall -O2 -fspec-constr-recursive=16 -fmax-worker-args=16
test-suite sf-test
if os(windows) -- not supported yet
build-depends: unbuildable<0
buildable: False
type: exitcode-stdio-1.0
main-is: Main.hs
hs-source-dirs: test
build-depends: base >= 4.12 && < 5
, bytestring
, hpath-directory >= 0.13
, hspec
, hspec-discover
, safe-exceptions >= 0.1
, streamly >= 0.7
, streamly-bytestring >= 0.1.0.1
, streamly-filesystem
, temporary
, unix >= 2.7
, word8 >= 0.1.3
default-language: Haskell2010
GHC-Options: -Wall -threaded -rtsopts -with-rtsopts=-N
source-repository head
type: git
location: https://github.com/hasufell/streamly-filesystem

39
test/Main.hs Normal file
View File

@ -0,0 +1,39 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.ByteString (ByteString)
import Data.Word (Word8)
import GHC.IO.Handle (Handle)
import Streamly
import Streamly.FileSystem.Handle (readChunks)
import Streamly.Memory.Array (Array)
import System.IO (openFile, IOMode(ReadMode))
import System.IO.Temp (withSystemTempFile)
import Test.Hspec
import Test.Hspec.QuickCheck
import qualified Data.ByteString as BS
import qualified Data.ByteString.Lazy as BSL
import Streamly.External.FileSystem.Handle.Posix
import qualified Streamly.Prelude as S
checkCopyLBS :: FilePath -> Handle -> IO ()
checkCopyLBS filename handle' = do
let content = "Some file content"
print $ "Checking " <> filename
handle <- openFile filename ReadMode
copyLBS content handle
bsContent <- BS.hGetContents handle'
bsContent `shouldBe` content
main :: IO ()
main =
hspec $ do
describe "Streamly.External.FileSystem.Handle.Posix" $ do
it "copyLBS" $
withSystemTempFile "x" checkCopyLBS