@@ -27,10 +27,52 @@ describe('Metadata Query', () => {
2727 limit : 100 ,
2828 } ,
2929 requestWithMultipleValues = {
30+ from : 'enterprise_123456.contractTemplate' ,
31+ query : 'name = :customerName' ,
32+ query_params : {
33+ value : 100 ,
34+ value2 : 'String' ,
35+ } ,
36+ fields : [
37+ 'created_at' ,
38+ 'metadata.enterprise_123456.contractTemplate.amount' ,
39+ 'metadata.enterprise_123456.contractTemplate.customerName' ,
40+ ] ,
41+ ancestor_folder_id : '5555' ,
42+ order_by : [
43+ {
44+ field_key : 'amount' ,
45+ direction : 'asc' ,
46+ } ,
47+ ] ,
48+ limit : 100 ,
49+ } ,
50+ requestWithMultipleArrayValues = {
51+ from : 'enterprise_123456.contractTemplate' ,
52+ query : 'name = :customerName' ,
53+ query_params : {
54+ customerName : [ 'John Doe' , 'Jane Doe' ] ,
55+ } ,
56+ fields : [
57+ 'created_at' ,
58+ 'metadata.enterprise_123456.contractTemplate.amount' ,
59+ 'metadata.enterprise_123456.contractTemplate.customerName' ,
60+ ] ,
61+ ancestor_folder_id : '5555' ,
62+ order_by : [
63+ {
64+ field_key : 'amount' ,
65+ direction : 'asc' ,
66+ } ,
67+ ] ,
68+ limit : 100 ,
69+ } ,
70+ requestWithMultipleArrayQueryParams = {
3071 from : 'enterprise_123456.contractTemplate' ,
3172 query : 'name = :customerName' ,
3273 query_params : {
3374 customerName : [ 'John Doe' , 'Jane Doe' ] ,
75+ customerName2 : [ 'Doe John' , 'Doe Jane' ] ,
3476 } ,
3577 fields : [
3678 'created_at' ,
@@ -81,15 +123,61 @@ describe('Metadata Query', () => {
81123 requestWithMultipleValues . from ,
82124 requestWithMultipleValues . ancestor_folder_id ,
83125 `--query=${ requestWithMultipleValues . query } ` ,
84- `--query-param-array=customerName=${ requestWithMultipleValues . query_params . customerName . join ( ',' ) } ` ,
126+ `--query-param=value=${ requestWithMultipleValues . query_params . value } f` ,
127+ `--query-param=value2=${ requestWithMultipleValues . query_params . value2 } ` ,
85128 `--extra-fields=${ requestWithMultipleValues . fields . join ( ',' ) } ` ,
86129 `--order-by=${ requestWithMultipleValues . order_by [ 0 ] . field_key } =${ requestWithMultipleValues . order_by [ 0 ] . direction } ` ,
87130 `--limit=${ requestWithMultipleValues . limit } ` ,
88131 '--json' ,
89132 '--token=test' ,
90133 ] )
134+ . it ( 'should query metadata with multiple query-param' , ctx => {
135+ assert . equal ( ctx . stdout , fixture ) ;
136+ } ) ;
137+
138+ test
139+ . nock ( TEST_API_ROOT , api => api
140+ . post ( '/2.0/metadata_queries/execute_read' , requestWithMultipleArrayValues )
141+ . reply ( 200 , fixture )
142+ )
143+ . stdout ( )
144+ . command ( [
145+ 'metadata-query' ,
146+ requestWithMultipleArrayValues . from ,
147+ requestWithMultipleArrayValues . ancestor_folder_id ,
148+ `--query=${ requestWithMultipleArrayValues . query } ` ,
149+ `--query-param-array=customerName=${ requestWithMultipleArrayValues . query_params . customerName . join ( ',' ) } ` ,
150+ `--extra-fields=${ requestWithMultipleArrayValues . fields . join ( ',' ) } ` ,
151+ `--order-by=${ requestWithMultipleArrayValues . order_by [ 0 ] . field_key } =${ requestWithMultipleArrayValues . order_by [ 0 ] . direction } ` ,
152+ `--limit=${ requestWithMultipleArrayValues . limit } ` ,
153+ '--json' ,
154+ '--token=test' ,
155+ ] )
91156 . it ( 'should query metadata with query-param' , ctx => {
92157 assert . equal ( ctx . stdout , fixture ) ;
93158 } ) ;
159+
160+ test
161+ . nock ( TEST_API_ROOT , api => api
162+ . post ( '/2.0/metadata_queries/execute_read' , requestWithMultipleArrayQueryParams )
163+ . reply ( 200 , fixture )
164+ )
165+ . stdout ( )
166+ . command ( [
167+ 'metadata-query' ,
168+ requestWithMultipleArrayQueryParams . from ,
169+ requestWithMultipleArrayQueryParams . ancestor_folder_id ,
170+ `--query=${ requestWithMultipleArrayQueryParams . query } ` ,
171+ `--query-param-array=customerName=${ requestWithMultipleArrayQueryParams . query_params . customerName . join ( ',' ) } ` ,
172+ `--query-param-array=customerName2=${ requestWithMultipleArrayQueryParams . query_params . customerName2 . join ( ',' ) } ` ,
173+ `--extra-fields=${ requestWithMultipleArrayQueryParams . fields . join ( ',' ) } ` ,
174+ `--order-by=${ requestWithMultipleArrayQueryParams . order_by [ 0 ] . field_key } =${ requestWithMultipleArrayQueryParams . order_by [ 0 ] . direction } ` ,
175+ `--limit=${ requestWithMultipleArrayQueryParams . limit } ` ,
176+ '--json' ,
177+ '--token=test' ,
178+ ] )
179+ . it ( 'should query metadata with multiple query-params-array' , ctx => {
180+ assert . equal ( ctx . stdout , fixture ) ;
181+ } ) ;
94182 } ) ;
95183} ) ;
0 commit comments