git.iko.soy/typeable/file-embed
on master help sign in
Added test suite
commit0bc86a5f0a7e970e466271571a4dac4d9ea88a87 authorMichael Snoyman <michael@snoyman.com> dateFri 27 May 2011, 06:49 (15 years ago) parent94748ac
3 files changed+25
runtests.hs+25 sample/.hidden sample/binary
runtests.hsnew file+25
@@ -0,0 +1,25 @@
1+{-# LANGUAGE TemplateHaskell #-}
2+import Test.Hspec
3+import Test.Hspec.HUnit
4+import Test.HUnit
5+
6+import Data.FileEmbed
7+import qualified Data.ByteString as S
8+import Data.List (sort)
9+
10+myeq x y = do
11+ y' <- y
12+ x @=? y'
13+
14+main = hspec $ descriptions
15+ [ describe "embedFile"
16+ [ it "handles text files" $ $(embedFile "sample/bar") `myeq` S.readFile "sample/bar"
17+ , it "handles binary files" $ $(embedFile "sample/binary") `myeq` S.readFile "sample/binary"
18+ ]
19+ , describe "getDir"
20+ [ it "takes all non-hidden files" $ ["bar", "baz", "bin", "binary"] `myeq` (fmap (sort . map fst) $ getDir "sample")
21+ ]
22+ , describe "embedDir"
23+ [ it "handles text and binary files" $ $(embedDir "sample") `myeq` getDir "sample"
24+ ]
25+ ]
sample/.hiddennew file

No changes to the content.

sample/binarynew file

Binary file not shown.