@@ -34,6 +34,7 @@ main = do
3434 errorTest
3535 freeTTest
3636 batchTest
37+ batchErrorTest
3738 where
3839 opts =
3940 { hostname: " localhost"
@@ -175,7 +176,7 @@ batchTest = do
175176 res <- requestWithBody opts batchBody
176177 body <- convertToString $ C .responseAsStream res
177178 liftEffect do
178- assert $ body == " [{\" status\" :503,\" headers\" :{\" X-Custom\" :\" CustomValue2\" ,\" Content-Type\" :\" application/json; charset=utf-8\" },\" body\" :{\" core\" :[\" This is error test\" ]}},{\" status\" :201,\" headers\" :{\" Content-Type\" :\" application/json; charset=utf-8\" },\" body\" :{\" name\" :\" Other Item 1\" }},{\" status\" :200,\" headers\" :{\" Content-Type\" :\" application/json; charset=utf-8\" },\" body\" :{\" name\" :\" authuser\" }},{\" status\" :404,\" headers\" :{\" Content-Type\" :\" application/json; charset=utf-8\" },\" body\" :null},{ \" status \" :500, \" headers \" :{ \" Content-Type \" : \" application/json; charset=utf-8 \" }, \" body \" :{ \" message \" : \" Internal server error \" }} ]"
179+ assert $ body == " [{\" status\" :503,\" headers\" :{\" X-Custom\" :\" CustomValue2\" ,\" Content-Type\" :\" application/json; charset=utf-8\" },\" body\" :{\" core\" :[\" This is error test\" ]}},{\" status\" :201,\" headers\" :{\" Content-Type\" :\" application/json; charset=utf-8\" },\" body\" :{\" name\" :\" Other Item 1\" }},{\" status\" :200,\" headers\" :{\" Content-Type\" :\" application/json; charset=utf-8\" },\" body\" :{\" name\" :\" authuser\" }},{\" status\" :404,\" headers\" :{\" Content-Type\" :\" application/json; charset=utf-8\" },\" body\" :null}]"
179180 assert $ C .statusCode res == 200
180181 where
181182 opts = C .port := 3000
@@ -188,5 +189,22 @@ batchTest = do
188189 , Tuple " X-Test-Auth" " authuser"
189190 ]
190191
192+ batchErrorTest :: Aff Unit
193+ batchErrorTest = do
194+ res <- requestWithBody opts batchErrorBody
195+ liftEffect $ assert $ C .statusCode res == 500
196+ where
197+ opts = C .port := 3000
198+ <> C .method := " POST"
199+ <> C .path := " /batch"
200+ <> C .headers := headers
201+ headers =
202+ C.RequestHeaders $ fromFoldable
203+ [ Tuple " Content-Type" " application/json"
204+ ]
205+
191206batchBody :: String
192- batchBody = " [{\" path\" :\" /failureTest\" },{\" path\" :\" /bodyTest\" ,\" body\" :{\" name\" :\" Other Item 1\" }},{\" path\" :\" /authTest\" },{\" path\" :\" /notFound\" },{\" path\" :\" /errorTest\" }]"
207+ batchBody = " [{\" path\" :\" /failureTest\" },{\" path\" :\" /bodyTest\" ,\" body\" :{\" name\" :\" Other Item 1\" }},{\" path\" :\" /authTest\" },{\" path\" :\" /notFound\" }]"
208+
209+ batchErrorBody :: String
210+ batchErrorBody = " [{\" path\" :\" /bodyTest\" ,\" body\" :{\" name\" :\" Other Item 1\" }},{\" path\" :\" /errorTest\" }]"
0 commit comments