Add test to insert into a view and expect location header return
This commit is contained in:
committed by
Steve Chavez
parent
a7403fecc2
commit
122fea1507
@@ -247,12 +247,11 @@ spec actualPgVersion = do
|
||||
|
||||
context "attempting to insert a row with the same primary key" $
|
||||
it "fails returning a 409 Conflict" $
|
||||
post "/simple_pk" [json| { "k":"k1", "extra":"e1" } |]
|
||||
post "/simple_pk"
|
||||
[json| { "k":"k1", "extra":"e1" } |]
|
||||
`shouldRespondWith`
|
||||
[json|{"hint":null,"details":"Key (k)=(k1) already exists.","code":"23505","message":"duplicate key value violates unique constraint \"contacts_pkey\""}|]
|
||||
{ matchStatus = 409
|
||||
, matchHeaders = [matchContentTypeJson]
|
||||
}
|
||||
[json|{"hint":null,"details":"Key (k)=(k1) already exists.","code":"23505","message":"duplicate key value violates unique constraint \"simple_pk_pkey\""}|]
|
||||
{ matchStatus = 409 }
|
||||
|
||||
context "attempting to insert a row with conflicting unique constraint" $
|
||||
it "fails returning a 409 Conflict" $
|
||||
@@ -494,3 +493,13 @@ spec actualPgVersion = do
|
||||
simpleBody p `shouldBe` ""
|
||||
simpleStatus p `shouldBe` created201
|
||||
|
||||
describe "Inserting into VIEWs" $
|
||||
it "returns a location header" $
|
||||
post "/compound_pk_view"
|
||||
[json|{"k1":1,"k2":"test","extra":2}|]
|
||||
`shouldRespondWith`
|
||||
""
|
||||
{ matchStatus = 201
|
||||
, matchHeaders = [ "Location" <:> "/compound_pk_view?k1=eq.1&k2=eq.test"
|
||||
, "Content-Range" <:> "*/*" ]
|
||||
}
|
||||
|
||||
Vendored
+1
@@ -23,6 +23,7 @@ GRANT ALL ON TABLE
|
||||
, comments
|
||||
, complex_items
|
||||
, compound_pk
|
||||
, compound_pk_view
|
||||
, empty_table
|
||||
, has_count_column
|
||||
, has_fk
|
||||
|
||||
Vendored
+8
-17
@@ -460,12 +460,19 @@ CREATE TABLE complex_items (
|
||||
--
|
||||
|
||||
CREATE TABLE compound_pk (
|
||||
-- those columns should not be referenced to in a foreign key anywhere
|
||||
-- to allow the InsertSpec.Inserting into VIEWs.returns a location header
|
||||
-- to test properly
|
||||
PRIMARY KEY (k1, k2),
|
||||
k1 integer NOT NULL,
|
||||
k2 text NOT NULL,
|
||||
extra integer
|
||||
);
|
||||
|
||||
|
||||
CREATE VIEW compound_pk_view AS
|
||||
SELECT * FROM compound_pk;
|
||||
|
||||
--
|
||||
-- Name: empty_table; Type: TABLE; Schema: test; Owner: -
|
||||
--
|
||||
@@ -632,6 +639,7 @@ CREATE VIEW projects_view_alt AS
|
||||
--
|
||||
|
||||
CREATE TABLE simple_pk (
|
||||
PRIMARY KEY (k),
|
||||
k character varying NOT NULL,
|
||||
extra character varying NOT NULL
|
||||
);
|
||||
@@ -785,23 +793,6 @@ ALTER TABLE ONLY auto_incrementing_pk
|
||||
ALTER TABLE ONLY complex_items
|
||||
ADD CONSTRAINT complex_items_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: compound_pk_pkey; Type: CONSTRAINT; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY compound_pk
|
||||
ADD CONSTRAINT compound_pk_pkey PRIMARY KEY (k1, k2);
|
||||
|
||||
|
||||
--
|
||||
-- Name: contacts_pkey; Type: CONSTRAINT; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY simple_pk
|
||||
ADD CONSTRAINT contacts_pkey PRIMARY KEY (k);
|
||||
|
||||
|
||||
--
|
||||
-- Name: has_fk_pkey; Type: CONSTRAINT; Schema: test; Owner: -
|
||||
--
|
||||
|
||||
Reference in New Issue
Block a user