diff --git a/Yesod/Helpers/Static.hs b/Yesod/Helpers/Static.hs index d7141388..36fa4645 100644 --- a/Yesod/Helpers/Static.hs +++ b/Yesod/Helpers/Static.hs @@ -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. -- diff --git a/runtests.hs b/runtests.hs deleted file mode 100644 index ccd8b724..00000000 --- a/runtests.hs +++ /dev/null @@ -1,6 +0,0 @@ -import Test.Framework (defaultMain) - -import Yesod.Helpers.Static - -main :: IO () -main = defaultMain [testSuite] diff --git a/test/.ignored b/tests/data/.ignored similarity index 100% rename from test/.ignored rename to tests/data/.ignored diff --git a/test/bar/baz b/tests/data/bar/baz similarity index 100% rename from test/bar/baz rename to tests/data/bar/baz diff --git a/test/foo b/tests/data/foo similarity index 100% rename from test/foo rename to tests/data/foo diff --git a/test/tmp/ignored b/tests/data/tmp/ignored similarity index 100% rename from test/tmp/ignored rename to tests/data/tmp/ignored diff --git a/tests/runtests.hs b/tests/runtests.hs new file mode 100644 index 00000000..3186a8e2 --- /dev/null +++ b/tests/runtests.hs @@ -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"]] diff --git a/yesod-static.cabal b/yesod-static.cabal index 99b4e97d..e9fe1456 100644 --- a/yesod-static.cabal +++ b/yesod-static.cabal @@ -7,7 +7,7 @@ maintainer: Michael Snoyman 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