diff --git a/postgrest.cabal b/postgrest.cabal index c92b90c43..7c4a50f08 100644 --- a/postgrest.cabal +++ b/postgrest.cabal @@ -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 diff --git a/test/Feature/AuthSpec.hs b/test/Feature/AuthSpec.hs index 7599322ea..b2228faa4 100644 --- a/test/Feature/AuthSpec.hs +++ b/test/Feature/AuthSpec.hs @@ -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 diff --git a/test/Feature/CorsSpec.hs b/test/Feature/CorsSpec.hs index feb5a58bd..353886926 100644 --- a/test/Feature/CorsSpec.hs +++ b/test/Feature/CorsSpec.hs @@ -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"), diff --git a/test/Feature/InsertSpec.hs b/test/Feature/InsertSpec.hs index 6e2173cd2..3e75e8657 100644 --- a/test/Feature/InsertSpec.hs +++ b/test/Feature/InsertSpec.hs @@ -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" diff --git a/test/Feature/QuerySpec.hs b/test/Feature/QuerySpec.hs index 5baa94a2e..ce0e0e75d 100644 --- a/test/Feature/QuerySpec.hs +++ b/test/Feature/QuerySpec.hs @@ -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 diff --git a/test/Feature/RangeSpec.hs b/test/Feature/RangeSpec.hs index b82c01ac4..311db4b37 100644 --- a/test/Feature/RangeSpec.hs +++ b/test/Feature/RangeSpec.hs @@ -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 diff --git a/test/Feature/StructureSpec.hs b/test/Feature/StructureSpec.hs index 776cf9ad2..98adf05c6 100644 --- a/test/Feature/StructureSpec.hs +++ b/test/Feature/StructureSpec.hs @@ -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 "/" [] "" diff --git a/test/Main.hs b/test/Main.hs new file mode 100644 index 000000000..ccd6171c1 --- /dev/null +++ b/test/Main.hs @@ -0,0 +1,9 @@ +{-# LANGUAGE QuasiQuotes #-} +module Main where + +import Test.Hspec +import SpecHelper +import Spec + +main :: IO () +main = resetDb >> hspec spec diff --git a/test/Spec.hs b/test/Spec.hs index a824f8c30..b4e92e756 100644 --- a/test/Spec.hs +++ b/test/Spec.hs @@ -1 +1 @@ -{-# OPTIONS_GHC -F -pgmF hspec-discover #-} +{-# OPTIONS_GHC -F -pgmF hspec-discover -optF --no-main #-} diff --git a/test/fixtures/schema.sql b/test/fixtures/schema.sql index 0c7cc5d7b..b2d199054 100755 --- a/test/fixtures/schema.sql +++ b/test/fixtures/schema.sql @@ -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); --