use cabal-test and hspec

This commit is contained in:
Greg Weber 2011-05-08 07:41:41 -07:00
parent 691ff7ba4e
commit 6f215c7f5f
8 changed files with 28 additions and 39 deletions

View File

@ -44,7 +44,7 @@ module Yesod.Helpers.Static
-- * Hashing
, base64md5
#if TEST
, testSuite
, getFileListPieces
#endif
) where
@ -76,12 +76,6 @@ import Network.Wai.Application.Static
, pathFromPieces
)
#if TEST
import Test.Framework (testGroup, Test)
import Test.Framework.Providers.HUnit
import Test.HUnit hiding (Test)
#endif
-- | generally static assets referenced in html files
-- assets get a checksum query parameter appended for perfect caching
-- * a far future expire date is set
@ -258,20 +252,6 @@ base64md5File file = do
contents <- L.readFile file
return $ base64md5 contents
#if TEST
testSuite :: Test
testSuite = testGroup "Yesod.Helpers.Static"
[ testCase "get file list" caseGetFileList
]
caseGetFileList :: Assertion
caseGetFileList = do
x <- getFileListPieces "test"
x @?= [["foo"], ["bar", "baz"]]
#endif
-- | md5-hashes the given lazy bytestring and returns the hash as
-- base64url-encoded string.
--

View File

@ -1,6 +0,0 @@
import Test.Framework (defaultMain)
import Yesod.Helpers.Static
main :: IO ()
main = defaultMain [testSuite]

17
tests/runtests.hs Normal file
View File

@ -0,0 +1,17 @@
{-# LANGUAGE OverloadedStrings #-}
import Yesod.Helpers.Static
import Test.Hspec
import Test.Hspec.HUnit ()
-- import Test.Hspec.QuickCheck (prop)
import Test.HUnit ((@?=))
main :: IO ()
main = hspecX specs
specs :: IO [Spec]
specs = runSpecM $ do
context "get file list" $ do
ti "pieces" $ do
x <- getFileListPieces "tests/data"
x @?= [["foo"], ["bar", "baz"]]

View File

@ -7,7 +7,7 @@ maintainer: Michael Snoyman <michael@snoyman.com>
synopsis: Static file serving subsite for Yesod Web Framework.
category: Web, Yesod
stability: Stable
cabal-version: >= 1.6
cabal-version: >= 1.8
build-type: Simple
homepage: http://www.yesodweb.com/
@ -32,17 +32,15 @@ library
exposed-modules: Yesod.Helpers.Static
ghc-options: -Wall
executable runtests
if flag(test)
Buildable: True
cpp-options: -DTEST
build-depends: test-framework,
test-framework-quickcheck2,
test-framework-hunit,
HUnit,
QuickCheck >= 2 && < 3
else
Buildable: False
test-suite runtests
hs-source-dirs: tests
main-is: runtests.hs
type: exitcode-stdio-1.0
cpp-options: -DTEST
build-depends: yesod-static,
base >= 4 && < 5,
hspec,
HUnit
ghc-options: -Wall
main-is: runtests.hs