@@ -111,6 +111,7 @@ describe('optic-update fromParam tests', function(){
111111 const planBuilderTemplate = op . fromParam ( 'myDocs' , 'qualifier' , outputCols ) ;
112112 const temp = { myDocs : rows } ;
113113 db . rows . query ( planBuilderTemplate , null , temp ) ;
114+ done ( new Error ( 'Expecting an error to be thrown due to invalid row-col-types argument' ) ) ;
114115 } catch ( e ) {
115116 e . toString ( ) . should . equal ( 'Error: row-col-types argument at 2 of PlanBuilder.fromParam() has invalid argument for PlanRowColTypes value: [object Object]' ) ;
116117 done ( ) ;
@@ -157,6 +158,7 @@ describe('optic-update fromParam tests', function(){
157158 const planBuilderTemplate = op . fromParam ( 'myDocs' , 'qualifier' , outputCols ) ;
158159 const temp = { myDocs : rows } ;
159160 db . rows . query ( planBuilderTemplate , null , temp ) ;
161+ done ( new Error ( 'Expecting an error to be thrown due to invalid row-col-types argument' ) ) ;
160162 } catch ( e ) {
161163 e . toString ( ) . should . equal ( 'Error: row-col-types argument at 2 of PlanBuilder.fromParam() has another type than string' ) ;
162164 done ( ) ;
@@ -205,7 +207,11 @@ describe('optic-update fromParam tests', function(){
205207 } , { "column" : "lastName" , "type" : "string" } ] ;
206208 const planBuilderTemplate = op . fromParam ( 'myDocs' , 'qualifier' , outputCols ) ;
207209 const temp = { myDocs : rows } ;
208- db . rows . query ( planBuilderTemplate , null , temp ) . catch ( e => {
210+ db . rows . query ( planBuilderTemplate , null , temp )
211+ . then ( function ( response ) {
212+ done ( new Error ( 'Expecting an error to be thrown due to null value for non-nullable column' ) ) ;
213+ } )
214+ . catch ( e => {
209215 e . toString ( ) . includes ( 'Error: binding arguments /v1/rows: cannot process response with 500 status' ) ;
210216 done ( ) ;
211217 } ) ;
@@ -221,7 +227,11 @@ describe('optic-update fromParam tests', function(){
221227 } , { "column" : "lastName" , "type" : "string" , "nullable" : true } ] ;
222228 const planBuilderTemplate = op . fromParam ( 'myDocs' , 'qualifier' , outputCols ) ;
223229 const temp = { myDocs : rows } ;
224- db . rows . query ( planBuilderTemplate , null , temp ) . catch ( e => {
230+ db . rows . query ( planBuilderTemplate , null , temp )
231+ . then ( function ( response ) {
232+ done ( new Error ( 'Expecting an error to be thrown due to invalid row-col-types argument' ) ) ;
233+ } )
234+ . catch ( e => {
225235 e . toString ( ) . includes ( 'Error: binding arguments /v1/rows: cannot process response with 500 status' ) ;
226236 done ( ) ;
227237 } ) ;
@@ -237,7 +247,11 @@ describe('optic-update fromParam tests', function(){
237247 } , { "column" : "lastName" , "type" : "string" , "nullable" : true } ] ;
238248 const planBuilderTemplate = op . fromParam ( 'myDocs' , 'qualifier' , outputCols ) ;
239249 const temp = { myDocs : rows } ;
240- db . rows . query ( planBuilderTemplate , null , temp ) . catch ( e => {
250+ db . rows . query ( planBuilderTemplate , null , temp )
251+ . then ( function ( response ) {
252+ done ( new Error ( 'Expecting an error to be thrown due to invalid row-col-types argument' ) ) ;
253+ } )
254+ . catch ( e => {
241255 e . toString ( ) . includes ( 'Error: binding arguments /v1/rows: cannot process response with 500 status' ) ;
242256 done ( ) ;
243257 } ) ;
@@ -255,10 +269,13 @@ describe('optic-update fromParam tests', function(){
255269 const planBuilderTemplate = op . fromParam ( 'myDocs' , null , outputCols ) ;
256270 const temp = { myDocs : rows } ;
257271 db . rows . query ( planBuilderTemplate , null , temp )
258- . catch ( e => {
259- e . toString ( ) . includes ( 'Error: binding arguments /v1/rows: cannot process response with 500 status' ) ;
260- done ( ) ;
261- } ) ;
272+ . then ( function ( response ) {
273+ done ( new Error ( 'Expecting an error to be thrown due to null value for non-nullable column' ) ) ;
274+ } )
275+ . catch ( e => {
276+ e . toString ( ) . includes ( 'Error: binding arguments /v1/rows: cannot process response with 500 status' ) ;
277+ done ( ) ;
278+ } ) ;
262279 } catch ( e ) {
263280 done ( ) ;
264281 }
@@ -274,10 +291,13 @@ describe('optic-update fromParam tests', function(){
274291 const planBuilderTemplate = op . fromParam ( 'myDocs' , null , outputCols ) ;
275292 const temp = { myDocs : rows } ;
276293 db . rows . query ( planBuilderTemplate , null , temp )
277- . catch ( e => {
278- e . toString ( ) . includes ( 'Error: binding arguments /v1/rows: cannot process response with 500 status' ) ;
279- done ( ) ;
280- } ) ;
294+ . then ( function ( response ) {
295+ done ( new Error ( 'Expecting an error to be thrown due to extra non-defined column types' ) ) ;
296+ } )
297+ . catch ( e => {
298+ e . toString ( ) . includes ( 'Error: binding arguments /v1/rows: cannot process response with 500 status' ) ;
299+ done ( ) ;
300+ } ) ;
281301
282302 } ) ;
283303
@@ -290,10 +310,13 @@ describe('optic-update fromParam tests', function(){
290310 const planBuilderTemplate = op . fromParam ( 'myDocs' , null , outputCols ) ;
291311 const temp = { bindingParam : rows } ;
292312 db . rows . query ( planBuilderTemplate , null , temp )
293- . catch ( e => {
294- e . toString ( ) . includes ( 'Error: binding arguments /v1/rows: cannot process response with 500 status' ) ;
295- done ( ) ;
296- } ) ;
313+ . then ( function ( response ) {
314+ done ( new Error ( 'Expecting an error to be thrown due to non-consistent binding argument name' ) ) ;
315+ } )
316+ . catch ( e => {
317+ e . toString ( ) . includes ( 'Error: binding arguments /v1/rows: cannot process response with 500 status' ) ;
318+ done ( ) ;
319+ } ) ;
297320
298321 } ) ;
299322
@@ -311,10 +334,13 @@ describe('optic-update fromParam tests', function(){
311334 const planBuilderTemplate = op . fromParam ( 'myDocs' , null , outputCols ) ;
312335 const temp = { myDocs : rows } ;
313336 db . rows . query ( planBuilderTemplate , null , temp )
314- . catch ( e => {
315- e . toString ( ) . includes ( 'Error: binding arguments /v1/rows: cannot process response with 500 status' ) ;
316- done ( ) ;
317- } ) ;
337+ . then ( function ( response ) {
338+ done ( new Error ( 'Expecting an error to be thrown due to mismatch type' ) ) ;
339+ } )
340+ . catch ( e => {
341+ e . toString ( ) . includes ( 'Error: binding arguments /v1/rows: cannot process response with 500 status' ) ;
342+ done ( ) ;
343+ } ) ;
318344
319345 } ) ;
320346
@@ -333,6 +359,7 @@ describe('optic-update fromParam tests', function(){
333359 const planBuilderTemplate = op . fromParam ( 'myDocs' , 1234 , outputCols ) ;
334360 const temp = { myDocs : rows } ;
335361 db . rows . query ( planBuilderTemplate , null , temp ) ;
362+ done ( new Error ( 'Expecting an error to be thrown due to invalid qualifier argument' ) ) ;
336363 } catch ( e ) {
337364 e . toString ( ) . includes ( 'Error: qualifier argument at 1 of PlanBuilder.fromParam() must be a XsString value' ) ;
338365 done ( ) ;
@@ -353,11 +380,17 @@ describe('optic-update fromParam tests', function(){
353380 const planBuilderTemplate = op . fromParam ( 'myDocs' , null , outputCols ) ;
354381 const temp = { myDocs : rows } ;
355382 db . rows . query ( planBuilderTemplate , null , temp ) . then ( res => {
356- const rows = res . rows ;
357- rows [ 0 ] . id . value . should . equal ( 1 ) ;
358- rows [ 0 ] . firstName . value . should . equal ( "firstName_1" ) ;
359- rows [ 0 ] . lastName . value . should . equal ( "lastName_1" ) ;
360- done ( ) ;
383+ try {
384+ const rows = res . rows ;
385+ rows [ 0 ] . id . value . should . equal ( 1 ) ;
386+ rows [ 0 ] . firstName . value . should . equal ( "firstName_1" ) ;
387+ rows [ 0 ] . lastName . value . should . equal ( "lastName_1" ) ;
388+ done ( ) ;
389+ } catch ( e ) {
390+ done ( e ) ;
391+ }
392+ } ) . catch ( e => {
393+ done ( e ) ;
361394 } ) ;
362395
363396 } ) ;
0 commit comments