Add test
This commit is contained in:
parent
126f23659e
commit
d30896b4d6
@ -33,6 +33,28 @@ library
|
|||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
GHC-Options: -Wall -O2 -fspec-constr-recursive=16 -fmax-worker-args=16
|
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
|
source-repository head
|
||||||
type: git
|
type: git
|
||||||
location: https://github.com/hasufell/streamly-filesystem
|
location: https://github.com/hasufell/streamly-filesystem
|
||||||
|
39
test/Main.hs
Normal file
39
test/Main.hs
Normal 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
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user