@@ -1,17 +1,21 @@
1−{-# LANGUAGE QuasiQuotes, TypeFamilies, GeneralizedNewtypeDeriving #-}
1+{-# LANGUAGE QuasiQuotes, TypeFamilies, GeneralizedNewtypeDeriving, GADTs #-}
22{-# LANGUAGE TemplateHaskell #-}
33{-# LANGUAGE OverloadedStrings #-}
4−module TestApp (testApp) where
4+module FullApp (fullApp) where
55
66import Network.Wai
7+import Network.HTTP.Types
78import Data.ByteString.Lazy.Char8 (pack)
9+import Database.Persist.TH
810import Database.Persist.Sqlite
911import System.Directory
1012import Control.Monad (when)
1113import Helper
1214import Text.Hamlet
15+import Text.Blaze.Renderer.Text (renderHtml)
16+import Data.Text.Lazy.Encoding (encodeUtf16LE)
1317
14−mkPersist [$persist|
18+mkPersist sqlSettings [persist|
1519Dummy
1620 dummy String
1721|]
@@ -19,10 +23,10 @@ Dummy
1923testApp handler = do
2024 putStrLn "testApp called, this should happen only once per reload"
2125 -- Swap between the following two lines as necessary to generate errors
22− exi <- doesFileExist db
26+ exi <- doesFileExist "db"
2327 --let exi = True
24− when exi $ removeFile db
25− withSqlitePool db 10 $ \pool -> do
28+ when exi $ removeFile "db"
29+ withSqlitePool "db" 10 $ \pool -> do
2630 flip runSqlPool pool $ runMigration $ migrate $ Dummy ""
2731 handler $ \req -> do
2832 if pathInfo req == "/favicon.ico"
@@ -34,7 +38,7 @@ testApp handler = do
3438 insert $ Dummy ""
3539 count ([] :: [Filter Dummy])
3640 return $ responseLBS status200
37− [("Content-Type", "text/html; charset=utf-8")]
38− $ renderHamlet id
39− $(hamletFile "hamlet/testapp.hamlet")
41+ [("Content-Type", "text/html; charset=utf-8")] $
42+ encodeUtf16LE $ renderHtml
43+ $(htmlFile "hamlet/testapp.hamlet")
4044 putStrLn "handler completed, this should only happen at the beginning of a reload"