Merge branch 'spec-cache-dbstructure'
This commit is contained in:
@@ -6,11 +6,15 @@ import Test.Hspec.Wai
|
||||
import Test.Hspec.Wai.JSON
|
||||
import Network.HTTP.Types
|
||||
|
||||
import Hasql as H
|
||||
import Hasql.Postgres as P
|
||||
|
||||
import SpecHelper
|
||||
import PostgREST.Types (DbStructure(..))
|
||||
-- }}}
|
||||
|
||||
spec :: Spec
|
||||
spec = around (withApp cfgDefault)
|
||||
spec :: DbStructure -> H.Pool P.Postgres -> Spec
|
||||
spec struct pool = around (withApp cfgDefault struct pool)
|
||||
$ describe "authorization" $ do
|
||||
|
||||
it "hides tables that anonymous does not own" $
|
||||
|
||||
@@ -6,13 +6,17 @@ import Test.Hspec.Wai
|
||||
import Network.Wai.Test (SResponse(simpleHeaders, simpleBody))
|
||||
import qualified Data.ByteString.Lazy as BL
|
||||
|
||||
import Hasql as H
|
||||
import Hasql.Postgres as P
|
||||
|
||||
import SpecHelper
|
||||
import PostgREST.Types (DbStructure(..))
|
||||
|
||||
import Network.HTTP.Types
|
||||
-- }}}
|
||||
|
||||
spec :: Spec
|
||||
spec = around (withApp cfgDefault) $ describe "CORS" $ do
|
||||
spec :: DbStructure -> H.Pool P.Postgres -> Spec
|
||||
spec struct pool = around (withApp cfgDefault struct pool) $ describe "CORS" $ do
|
||||
let preflightHeaders = [
|
||||
("Accept", "*/*"),
|
||||
("Origin", "http://example.com"),
|
||||
|
||||
@@ -2,13 +2,18 @@ module Feature.DeleteSpec where
|
||||
|
||||
import Test.Hspec
|
||||
import Test.Hspec.Wai
|
||||
|
||||
import Hasql as H
|
||||
import Hasql.Postgres as P
|
||||
|
||||
import SpecHelper
|
||||
import PostgREST.Types (DbStructure(..))
|
||||
|
||||
import Network.HTTP.Types
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll resetDb
|
||||
. around (withApp cfgDefault) $
|
||||
spec :: DbStructure -> H.Pool P.Postgres -> Spec
|
||||
spec struct pool = beforeAll resetDb
|
||||
. around (withApp cfgDefault struct pool) $
|
||||
describe "Deleting" $ do
|
||||
context "existing record" $ do
|
||||
it "succeeds with 204 and deletion count" $
|
||||
|
||||
@@ -5,7 +5,11 @@ import Test.Hspec.Wai
|
||||
import Test.Hspec.Wai.JSON
|
||||
import Network.Wai.Test (SResponse(simpleBody,simpleHeaders,simpleStatus))
|
||||
|
||||
import Hasql as H
|
||||
import Hasql.Postgres as P
|
||||
|
||||
import SpecHelper
|
||||
import PostgREST.Types (DbStructure(..))
|
||||
|
||||
import qualified Data.Aeson as JSON
|
||||
import Data.Maybe (fromJust)
|
||||
@@ -16,8 +20,8 @@ import Control.Monad (replicateM_)
|
||||
|
||||
import TestTypes(IncPK(..), CompoundPK(..))
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll_ resetDb $ around (withApp cfgDefault) $ do
|
||||
spec :: DbStructure -> H.Pool P.Postgres -> Spec
|
||||
spec struct pool = beforeAll_ resetDb $ around (withApp cfgDefault struct pool) $ do
|
||||
describe "Posting new record" $ do
|
||||
after_ (clearTable "menagerie") . context "disparate csv types" $ do
|
||||
it "accepts disparate json types" $ do
|
||||
|
||||
@@ -6,12 +6,16 @@ import Test.Hspec.Wai.JSON
|
||||
import Network.HTTP.Types
|
||||
import Network.Wai.Test (SResponse(simpleHeaders, simpleStatus))
|
||||
|
||||
import SpecHelper
|
||||
import Hasql as H
|
||||
import Hasql.Postgres as P
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
import SpecHelper
|
||||
import PostgREST.Types (DbStructure(..))
|
||||
|
||||
spec :: DbStructure -> H.Pool P.Postgres -> Spec
|
||||
spec struct pool =
|
||||
beforeAll resetDb
|
||||
. around (withApp $ cfgLimitRows 3) $
|
||||
. around (withApp (cfgLimitRows 3) struct pool) $
|
||||
describe "Requesting many items with server limits enabled" $ do
|
||||
it "restricts results" $
|
||||
get "/items"
|
||||
|
||||
@@ -6,12 +6,15 @@ import Test.Hspec.Wai.JSON
|
||||
import Network.HTTP.Types
|
||||
import Network.Wai.Test (SResponse(simpleHeaders))
|
||||
|
||||
import Hasql as H
|
||||
import Hasql.Postgres as P
|
||||
|
||||
import SpecHelper
|
||||
import PostgREST.Types (DbStructure(..))
|
||||
import Text.Heredoc
|
||||
|
||||
|
||||
spec :: Spec
|
||||
spec = around (withApp cfgDefault) $ do
|
||||
spec :: DbStructure -> H.Pool P.Postgres -> Spec
|
||||
spec struct pool = around (withApp cfgDefault struct pool) $ do
|
||||
|
||||
describe "Querying a table with a column called count" $
|
||||
it "should not confuse count column with pg_catalog.count aggregate" $
|
||||
@@ -219,6 +222,11 @@ spec = around (withApp cfgDefault) $ do
|
||||
get "/users_tasks?user_id=eq.2&task_id=eq.6&select=*, comments{content}" `shouldRespondWith`
|
||||
"[{\"user_id\":2,\"task_id\":6,\"comments\":[{\"content\":\"Needs to be delivered ASAP\"}]}]"
|
||||
|
||||
it "detect relations in views from exposed schema that are based on tables in private schema and have columns renames" $
|
||||
get "/articles?id=eq.1&select=id,articleStars{users{*}}" `shouldRespondWith`
|
||||
[str|[{"id":1,"articlestars":[{"users":{"id":1,"name":"Angela Martin"}},{"users":{"id":2,"name":"Michael Scott"}},{"users":{"id":3,"name":"Dwight Schrute"}}]}]|]
|
||||
|
||||
|
||||
describe "Plurality singular" $ do
|
||||
it "will select an existing object" $
|
||||
request methodGet "/items?id=eq.5" [("Prefer","plurality=singular")] ""
|
||||
|
||||
@@ -6,11 +6,15 @@ import Test.Hspec.Wai.JSON
|
||||
import Network.HTTP.Types
|
||||
import Network.Wai.Test (SResponse(simpleHeaders,simpleStatus))
|
||||
|
||||
import SpecHelper
|
||||
import Hasql as H
|
||||
import Hasql.Postgres as P
|
||||
|
||||
spec :: Spec
|
||||
spec = beforeAll resetDb
|
||||
. around (withApp cfgDefault) $
|
||||
import SpecHelper
|
||||
import PostgREST.Types (DbStructure(..))
|
||||
|
||||
spec :: DbStructure -> H.Pool P.Postgres -> Spec
|
||||
spec struct pool = beforeAll resetDb
|
||||
. around (withApp cfgDefault struct pool) $
|
||||
describe "GET /items" $ do
|
||||
|
||||
context "without range headers" $ do
|
||||
|
||||
@@ -4,12 +4,16 @@ import Test.Hspec hiding (pendingWith)
|
||||
import Test.Hspec.Wai
|
||||
import Test.Hspec.Wai.JSON
|
||||
|
||||
import Hasql as H
|
||||
import Hasql.Postgres as P
|
||||
|
||||
import SpecHelper
|
||||
import PostgREST.Types (DbStructure(..))
|
||||
|
||||
import Network.HTTP.Types
|
||||
|
||||
spec :: Spec
|
||||
spec = around (withApp cfgDefault) $ do
|
||||
spec :: DbStructure -> H.Pool P.Postgres -> Spec
|
||||
spec struct pool = around (withApp cfgDefault struct pool) $ do
|
||||
describe "GET /" $ do
|
||||
it "lists views in schema" $
|
||||
request methodGet "/" [] ""
|
||||
@@ -208,16 +212,14 @@ spec = around (withApp cfgDefault) $ do
|
||||
}
|
||||
|]
|
||||
|
||||
it "includes foreign key data" $ do
|
||||
pendingWith "have to resolve issue #107"
|
||||
|
||||
it "includes foreign key data" $
|
||||
request methodOptions "/has_fk" [] ""
|
||||
`shouldRespondWith` [json|
|
||||
{
|
||||
"pkey": ["id"],
|
||||
"columns":[
|
||||
{
|
||||
"default": "nextval('\"1\".has_fk_id_seq'::regclass)",
|
||||
"default": "nextval('test.has_fk_id_seq'::regclass)",
|
||||
"precision": 64,
|
||||
"updatable": true,
|
||||
"schema": "test",
|
||||
@@ -239,7 +241,7 @@ spec = around (withApp cfgDefault) $ do
|
||||
"nullable": true,
|
||||
"position": 2,
|
||||
"enum": [],
|
||||
"references": {"table": "auto_incrementing_pk", "column": "id"}
|
||||
"references": {"schema":"test", "table": "auto_incrementing_pk", "column": "id"}
|
||||
}, {
|
||||
"default": null,
|
||||
"precision": null,
|
||||
@@ -251,14 +253,13 @@ spec = around (withApp cfgDefault) $ do
|
||||
"nullable": true,
|
||||
"position": 3,
|
||||
"enum": [],
|
||||
"references": {"table": "simple_pk", "column": "k"}
|
||||
"references": {"schema":"test", "table": "simple_pk", "column": "k"}
|
||||
}
|
||||
]
|
||||
}
|
||||
|]
|
||||
|
||||
it "includes all information on views for renamed columns, and raises relations to correct schema" $ do
|
||||
pendingWith "have to resolve issue #107"
|
||||
it "includes all information on views for renamed columns, and raises relations to correct schema" $
|
||||
request methodOptions "/articleStars" [] ""
|
||||
`shouldRespondWith` [json|
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user