create items in test, not in the schema.
This commit is contained in:
@@ -13,25 +13,11 @@ import Data.Maybe (fromJust)
|
||||
import Network.HTTP.Types.Header
|
||||
import Network.HTTP.Types
|
||||
import Control.Monad (replicateM_)
|
||||
import Data.Monoid
|
||||
import qualified Hasql as H
|
||||
import qualified Data.ByteString.Char8 as BS
|
||||
|
||||
import TestTypes(IncPK(..), CompoundPK(..))
|
||||
|
||||
--import Debug.Trace
|
||||
|
||||
|
||||
clearTable :: BS.ByteString -> IO ()
|
||||
clearTable table = H.session pgSettings testSettings $ H.tx Nothing $
|
||||
H.unit ("delete from \"1\"."<>table, [], True)
|
||||
|
||||
createItems :: Int -> IO ()
|
||||
createItems n = H.session pgSettings testSettings $ H.tx Nothing txn >> return ()
|
||||
where
|
||||
txn = sequence $ map H.unit stmts
|
||||
stmts = map [H.q|insert into "1".items (id) values (?)|] [1..n]
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll resetDb $ around withApp $ do
|
||||
describe "Posting new record" $ do
|
||||
|
||||
@@ -6,7 +6,10 @@ import Test.Hspec.Wai
|
||||
import SpecHelper
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll resetDb $ around withApp $ do
|
||||
spec = beforeAll (do
|
||||
resetDb
|
||||
createItems 15
|
||||
) . afterAll_ (clearTable "items") . around withApp $ do
|
||||
describe "Querying a nonexistent table" $
|
||||
it "causes a 404" $
|
||||
get "/faketable" `shouldRespondWith` 404
|
||||
|
||||
@@ -8,7 +8,8 @@ import Network.Wai.Test (SResponse(simpleHeaders,simpleStatus))
|
||||
import SpecHelper
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll resetDb $ around withApp $
|
||||
spec = beforeAll (resetDb >> createItems 15) . afterAll_ (clearTable "items")
|
||||
. around withApp $
|
||||
describe "GET /items" $ do
|
||||
|
||||
context "without range headers" $
|
||||
|
||||
Reference in New Issue
Block a user