only create schema once
This commit is contained in:
+1
-1
@@ -56,7 +56,7 @@ Test-Suite spec
|
||||
other-extensions: QuasiQuotes
|
||||
Hs-Source-Dirs: test, src
|
||||
ghc-options: -Wall -W -Werror
|
||||
Main-Is: Spec.hs
|
||||
Main-Is: Main.hs
|
||||
Other-Modules: App, Auth, Config, Spec, SpecHelper
|
||||
Build-Depends: base, hspec >= 2.1.2, QuickCheck
|
||||
, hspec-wai >= 0.5.0, hspec-wai-json
|
||||
|
||||
@@ -11,8 +11,7 @@ import SpecHelper
|
||||
-- }}}
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll resetDb $ around withApp $
|
||||
describe "authorization" $ do
|
||||
spec = around withApp $ describe "authorization" $ do
|
||||
it "hides tables that anonymous does not own" $
|
||||
get "/authors_only" `shouldRespondWith` 404
|
||||
it "indicates login failure" $ do
|
||||
|
||||
@@ -12,8 +12,7 @@ import Network.HTTP.Types
|
||||
-- }}}
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll resetDb $ around withApp $
|
||||
describe "CORS" $ do
|
||||
spec = around withApp $ describe "CORS" $ do
|
||||
let preflightHeaders = [
|
||||
("Accept", "*/*"),
|
||||
("Origin", "http://example.com"),
|
||||
|
||||
@@ -19,7 +19,7 @@ import TestTypes(IncPK(..), CompoundPK(..))
|
||||
--import Debug.Trace
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll resetDb $ around withApp $ do
|
||||
spec = around withApp $ do
|
||||
describe "Posting new record" $ do
|
||||
after_ (clearTable "menagerie") . it "accepts disparate json types" $ do
|
||||
p <- post "/menagerie"
|
||||
|
||||
@@ -6,10 +6,8 @@ import Test.Hspec.Wai
|
||||
import SpecHelper
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll (do
|
||||
resetDb
|
||||
createItems 15
|
||||
) . afterAll_ (clearTable "items") . around withApp $ do
|
||||
spec = beforeAll (clearTable "items" >> createItems 15)
|
||||
. afterAll_ (clearTable "items") . around withApp $ do
|
||||
describe "Querying a nonexistent table" $
|
||||
it "causes a 404" $
|
||||
get "/faketable" `shouldRespondWith` 404
|
||||
|
||||
@@ -8,7 +8,7 @@ import Network.Wai.Test (SResponse(simpleHeaders,simpleStatus))
|
||||
import SpecHelper
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll (resetDb >> createItems 15) . afterAll_ (clearTable "items")
|
||||
spec = beforeAll (clearTable "items" >> createItems 15) . afterAll_ (clearTable "items")
|
||||
. around withApp $
|
||||
describe "GET /items" $ do
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import SpecHelper
|
||||
import Network.HTTP.Types
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll resetDb $ around withApp $ do
|
||||
spec = around withApp $ do
|
||||
describe "GET /" $ do
|
||||
it "lists views in schema" $
|
||||
request methodGet "/" [] ""
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
{-# LANGUAGE QuasiQuotes #-}
|
||||
module Main where
|
||||
|
||||
import Test.Hspec
|
||||
import SpecHelper
|
||||
import Spec
|
||||
|
||||
main :: IO ()
|
||||
main = resetDb >> hspec spec
|
||||
+1
-1
@@ -1 +1 @@
|
||||
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
|
||||
{-# OPTIONS_GHC -F -pgmF hspec-discover -optF --no-main #-}
|
||||
|
||||
Vendored
+2
-1
@@ -452,13 +452,14 @@ SELECT pg_catalog.setval('has_fk_id_seq', 1, false);
|
||||
-- Data for Name: items; Type: TABLE DATA; Schema: 1; Owner: postgrest_test
|
||||
--
|
||||
|
||||
INSERT INTO items (id) VALUES (1);
|
||||
--
|
||||
-- TOC entry 2339 (class 0 OID 0)
|
||||
-- Dependencies: 198
|
||||
-- Name: items_id_seq; Type: SEQUENCE SET; Schema: 1; Owner: postgrest_test
|
||||
--
|
||||
|
||||
SELECT pg_catalog.setval('items_id_seq', 1, true);
|
||||
SELECT pg_catalog.setval('items_id_seq', 19, true);
|
||||
|
||||
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user