diff --git a/test/Feature/InsertSpec.hs b/test/Feature/InsertSpec.hs index 3f4c82955..86bc24c19 100644 --- a/test/Feature/InsertSpec.hs +++ b/test/Feature/InsertSpec.hs @@ -33,7 +33,7 @@ instance JSON.FromJSON IncPK where spec :: Spec spec = around appWithFixture $ describe "Posting new record" $ - context "with no pk supplied" $ + context "with no pk supplied" $ do context "into a table with auto-incrementing pk" $ it "succeeds with 201 and link" $ do post "/auto_incrementing_pk" [json| { "non_nullable_string":"not null"} |] @@ -47,3 +47,8 @@ spec = around appWithFixture $ liftIO $ do incStr record `shouldBe` "not null" incNullableStr record `shouldBe` Nothing + + context "into a table with simple pk" $ + it "fails with 400 and error" $ + post "/contacts" [json| { "name":"J Doe"} |] + `shouldRespondWith` 400 diff --git a/test/Feature/RangeSpec.hs b/test/Feature/RangeSpec.hs index bbd073ad9..b7723a8fb 100644 --- a/test/Feature/RangeSpec.hs +++ b/test/Feature/RangeSpec.hs @@ -11,62 +11,6 @@ import Network.HTTP.Types spec :: Spec spec = around appWithFixture $ do - describe "GET /" $ do - it "responds with 200" $ - get "/" `shouldRespondWith` 200 - - it "lists views in schema" $ - get "/" `shouldRespondWith` [json| - [{"schema":"1","name":"auto_incrementing_pk","insertable":true}] - |] - - describe "Table info" $ - it "is available with OPTIONS verb" $ - -- {{{ big json object - request methodOptions "/auto_incrementing_pk" "" `shouldRespondWith` [json| - { - "pkey":["id"], - "columns":{ - "inserted_at":{ - "precision":null, - "updatable":true, - "schema":"1", - "name":"inserted_at", - "type":"timestamp with time zone", - "maxLen":null, - "nullable":true, - "position":4}, - "id":{ - "precision":32, - "updatable":true, - "schema":"1", - "name":"id", - "type":"integer", - "maxLen":null, - "nullable":false, - "position":1}, - "non_nullable_string":{ - "precision":null, - "updatable":true, - "schema":"1", - "name":"non_nullable_string", - "type":"character varying", - "maxLen":null, - "nullable":false, - "position":3}, - "nullable_string":{ - "precision":null, - "updatable":true, - "schema":"1", - "name":"nullable_string", - "type":"character varying", - "maxLen":null, - "nullable":true, - "position":2}} - } - |] - -- }}} - describe "GET /view" $ context "without range headers" $ context "with response under server size limit" $ diff --git a/test/Feature/StructureSpec.hs b/test/Feature/StructureSpec.hs index a020edddd..2f24fc6e5 100644 --- a/test/Feature/StructureSpec.hs +++ b/test/Feature/StructureSpec.hs @@ -14,7 +14,10 @@ spec = around appWithFixture $ do describe "GET /" $ it "lists views in schema" $ get "/" `shouldRespondWith` - [json| [{"schema":"1","name":"auto_incrementing_pk","insertable":true}] |] + [json| [ + {"schema":"1","name":"auto_incrementing_pk","insertable":true}, + {"schema":"1","name":"contacts","insertable":true}] + |] {matchStatus = 200} describe "Table info" $ diff --git a/test/fixtures/schema.sql b/test/fixtures/schema.sql index bb02c69a5..f9f042193 100644 --- a/test/fixtures/schema.sql +++ b/test/fixtures/schema.sql @@ -4,7 +4,7 @@ -- Dumped from database version 9.3.4 -- Dumped by pg_dump version 9.3.1 --- Started on 2014-08-14 13:19:39 PDT +-- Started on 2014-08-25 17:13:38 PDT SET statement_timeout = 0; SET lock_timeout = 0; @@ -14,7 +14,7 @@ SET check_function_bodies = false; SET client_min_messages = warning; -- --- TOC entry 6 (class 2615 OID 226754) +-- TOC entry 6 (class 2615 OID 229843) -- Name: 1; Type: SCHEMA; Schema: -; Owner: - -- @@ -22,7 +22,7 @@ CREATE SCHEMA "1"; -- --- TOC entry 172 (class 3079 OID 12018) +-- TOC entry 173 (class 3079 OID 12018) -- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: - -- @@ -30,8 +30,8 @@ CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog; -- --- TOC entry 2206 (class 0 OID 0) --- Dependencies: 172 +-- TOC entry 2213 (class 0 OID 0) +-- Dependencies: 173 -- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: - -- @@ -45,7 +45,7 @@ SET default_tablespace = ''; SET default_with_oids = false; -- --- TOC entry 170 (class 1259 OID 226755) +-- TOC entry 170 (class 1259 OID 229844) -- Name: auto_incrementing_pk; Type: TABLE; Schema: 1; Owner: -; Tablespace: -- @@ -58,7 +58,7 @@ CREATE TABLE auto_incrementing_pk ( -- --- TOC entry 171 (class 1259 OID 226762) +-- TOC entry 171 (class 1259 OID 229851) -- Name: auto_incrementing_pk_id_seq; Type: SEQUENCE; Schema: 1; Owner: - -- @@ -71,7 +71,7 @@ CREATE SEQUENCE auto_incrementing_pk_id_seq -- --- TOC entry 2207 (class 0 OID 0) +-- TOC entry 2214 (class 0 OID 0) -- Dependencies: 171 -- Name: auto_incrementing_pk_id_seq; Type: SEQUENCE OWNED BY; Schema: 1; Owner: - -- @@ -80,7 +80,18 @@ ALTER SEQUENCE auto_incrementing_pk_id_seq OWNED BY auto_incrementing_pk.id; -- --- TOC entry 2091 (class 2604 OID 226764) +-- TOC entry 172 (class 1259 OID 229859) +-- Name: contacts; Type: TABLE; Schema: 1; Owner: -; Tablespace: +-- + +CREATE TABLE contacts ( + email character varying NOT NULL, + name character varying NOT NULL +); + + +-- +-- TOC entry 2096 (class 2604 OID 229853) -- Name: id; Type: DEFAULT; Schema: 1; Owner: - -- @@ -88,7 +99,7 @@ ALTER TABLE ONLY auto_incrementing_pk ALTER COLUMN id SET DEFAULT nextval('auto_ -- --- TOC entry 2093 (class 2606 OID 226766) +-- TOC entry 2098 (class 2606 OID 229855) -- Name: auto_incrementing_pk_pkey; Type: CONSTRAINT; Schema: 1; Owner: -; Tablespace: -- @@ -96,7 +107,16 @@ ALTER TABLE ONLY auto_incrementing_pk ADD CONSTRAINT auto_incrementing_pk_pkey PRIMARY KEY (id); --- Completed on 2014-08-14 13:19:39 PDT +-- +-- TOC entry 2100 (class 2606 OID 229866) +-- Name: contacts_pkey; Type: CONSTRAINT; Schema: 1; Owner: -; Tablespace: +-- + +ALTER TABLE ONLY contacts + ADD CONSTRAINT contacts_pkey PRIMARY KEY (email); + + +-- Completed on 2014-08-25 17:13:38 PDT -- -- PostgreSQL database dump complete