only create schema once

This commit is contained in:
Adam C. Baker
2014-12-29 17:57:31 -08:00
parent 23a75aefcc
commit c9b960f955
10 changed files with 20 additions and 14 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ Test-Suite spec
other-extensions: QuasiQuotes other-extensions: QuasiQuotes
Hs-Source-Dirs: test, src Hs-Source-Dirs: test, src
ghc-options: -Wall -W -Werror ghc-options: -Wall -W -Werror
Main-Is: Spec.hs Main-Is: Main.hs
Other-Modules: App, Auth, Config, Spec, SpecHelper Other-Modules: App, Auth, Config, Spec, SpecHelper
Build-Depends: base, hspec >= 2.1.2, QuickCheck Build-Depends: base, hspec >= 2.1.2, QuickCheck
, hspec-wai >= 0.5.0, hspec-wai-json , hspec-wai >= 0.5.0, hspec-wai-json
+1 -2
View File
@@ -11,8 +11,7 @@ import SpecHelper
-- }}} -- }}}
spec :: Spec spec :: Spec
spec = beforeAll resetDb $ around withApp $ spec = around withApp $ describe "authorization" $ do
describe "authorization" $ do
it "hides tables that anonymous does not own" $ it "hides tables that anonymous does not own" $
get "/authors_only" `shouldRespondWith` 404 get "/authors_only" `shouldRespondWith` 404
it "indicates login failure" $ do it "indicates login failure" $ do
+1 -2
View File
@@ -12,8 +12,7 @@ import Network.HTTP.Types
-- }}} -- }}}
spec :: Spec spec :: Spec
spec = beforeAll resetDb $ around withApp $ spec = around withApp $ describe "CORS" $ do
describe "CORS" $ do
let preflightHeaders = [ let preflightHeaders = [
("Accept", "*/*"), ("Accept", "*/*"),
("Origin", "http://example.com"), ("Origin", "http://example.com"),
+1 -1
View File
@@ -19,7 +19,7 @@ import TestTypes(IncPK(..), CompoundPK(..))
--import Debug.Trace --import Debug.Trace
spec :: Spec spec :: Spec
spec = beforeAll resetDb $ around withApp $ do spec = around withApp $ do
describe "Posting new record" $ do describe "Posting new record" $ do
after_ (clearTable "menagerie") . it "accepts disparate json types" $ do after_ (clearTable "menagerie") . it "accepts disparate json types" $ do
p <- post "/menagerie" p <- post "/menagerie"
+2 -4
View File
@@ -6,10 +6,8 @@ import Test.Hspec.Wai
import SpecHelper import SpecHelper
spec :: Spec spec :: Spec
spec = beforeAll (do spec = beforeAll (clearTable "items" >> createItems 15)
resetDb . afterAll_ (clearTable "items") . around withApp $ do
createItems 15
) . afterAll_ (clearTable "items") . around withApp $ do
describe "Querying a nonexistent table" $ describe "Querying a nonexistent table" $
it "causes a 404" $ it "causes a 404" $
get "/faketable" `shouldRespondWith` 404 get "/faketable" `shouldRespondWith` 404
+1 -1
View File
@@ -8,7 +8,7 @@ import Network.Wai.Test (SResponse(simpleHeaders,simpleStatus))
import SpecHelper import SpecHelper
spec :: Spec spec :: Spec
spec = beforeAll (resetDb >> createItems 15) . afterAll_ (clearTable "items") spec = beforeAll (clearTable "items" >> createItems 15) . afterAll_ (clearTable "items")
. around withApp $ . around withApp $
describe "GET /items" $ do describe "GET /items" $ do
+1 -1
View File
@@ -10,7 +10,7 @@ import SpecHelper
import Network.HTTP.Types import Network.HTTP.Types
spec :: Spec spec :: Spec
spec = beforeAll resetDb $ around withApp $ do spec = around withApp $ do
describe "GET /" $ do describe "GET /" $ do
it "lists views in schema" $ it "lists views in schema" $
request methodGet "/" [] "" request methodGet "/" [] ""
+9
View File
@@ -0,0 +1,9 @@
{-# LANGUAGE QuasiQuotes #-}
module Main where
import Test.Hspec
import SpecHelper
import Spec
main :: IO ()
main = resetDb >> hspec spec
+1 -1
View File
@@ -1 +1 @@
{-# OPTIONS_GHC -F -pgmF hspec-discover #-} {-# OPTIONS_GHC -F -pgmF hspec-discover -optF --no-main #-}
+2 -1
View File
@@ -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 -- 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) -- TOC entry 2339 (class 0 OID 0)
-- Dependencies: 198 -- Dependencies: 198
-- Name: items_id_seq; Type: SEQUENCE SET; Schema: 1; Owner: postgrest_test -- 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);
-- --