@@ -157,36 +157,75 @@ describe('#deploy-cloudrun', function () {
157157 } ) ;
158158 } ) ;
159159
160- describe ( '#parseFlags' , function ( ) {
161- it ( 'parses flags using equals' , async function ( ) {
162- const input = '--concurrency=2 --memory=2Gi' ;
163- const results = parseFlags ( input ) ;
164- expect ( results ) . to . eql ( [ '--concurrency' , '2' , '--memory' , '2Gi' ] ) ;
165- } ) ;
166- it ( 'parses flags using spaces' , async function ( ) {
167- const input = '--concurrency 2 --memory 2Gi' ;
168- const results = parseFlags ( input ) ;
169- expect ( results ) . to . eql ( [ '--concurrency' , '2' , '--memory' , '2Gi' ] ) ;
170- } ) ;
171- it ( 'parses flags using combo' , async function ( ) {
172- const input = '--concurrency 2 --memory=2Gi' ;
173- const results = parseFlags ( input ) ;
174- expect ( results ) . to . eql ( [ '--concurrency' , '2' , '--memory' , '2Gi' ] ) ;
175- } ) ;
176- it ( 'parses flags using space and quotes combo' , async function ( ) {
177- const input = '--concurrency 2 --memory="2 Gi"' ;
178- const results = parseFlags ( input ) ;
179- expect ( results ) . to . eql ( [ '--concurrency' , '2' , '--memory' , '"2 Gi"' ] ) ;
180- } ) ;
181- it ( 'parses flags using space and quotes' , async function ( ) {
182- const input = '--entry-point "node index.js"' ;
183- const results = parseFlags ( input ) ;
184- expect ( results ) . to . eql ( [ '--entry-point' , '"node index.js"' ] ) ;
185- } ) ;
186- it ( 'parses flags using equals and quotes' , async function ( ) {
187- const input = '--entry-point="node index.js"' ;
188- const results = parseFlags ( input ) ;
189- expect ( results ) . to . eql ( [ '--entry-point' , '"node index.js"' ] ) ;
160+ describe ( '#parseFlags' , ( ) => {
161+ const cases = [
162+ {
163+ name : `with equals` ,
164+ input : `--concurrency=2 --memory=2Gi` ,
165+ exp : [ `--concurrency` , `2` , `--memory` , `2Gi` ] ,
166+ } ,
167+ {
168+ name : `with spaces` ,
169+ input : `--concurrency 2 --memory 2Gi` ,
170+ exp : [ `--concurrency` , `2` , `--memory` , `2Gi` ] ,
171+ } ,
172+ {
173+ name : `with equals and spaces` ,
174+ input : `--concurrency 2 --memory=2Gi` ,
175+ exp : [ `--concurrency` , `2` , `--memory` , `2Gi` ] ,
176+ } ,
177+ {
178+ name : `with equals and double quotes` ,
179+ input : `--memory="2Gi"` ,
180+ exp : [ `--memory` , `"2Gi"` ] ,
181+ } ,
182+ {
183+ name : `with space and double quotes` ,
184+ input : `--memory "2Gi"` ,
185+ exp : [ `--memory` , `"2Gi"` ] ,
186+ } ,
187+ {
188+ name : `with equals and space and double quotes` ,
189+ input : `--memory="2Gi" --concurrency "2"` ,
190+ exp : [ `--memory` , `"2Gi"` , `--concurrency` , `"2"` ] ,
191+ } ,
192+ {
193+ name : `with equals and space and some double quotes` ,
194+ input : `--memory="2Gi" --concurrency 2` ,
195+ exp : [ `--memory` , `"2Gi"` , `--concurrency` , `2` ] ,
196+ } ,
197+ {
198+ name : `with equals and single quotes` ,
199+ input : `--memory='2Gi'` ,
200+ exp : [ `--memory` , `'2Gi'` ] ,
201+ } ,
202+ {
203+ name : `with space and single quotes` ,
204+ input : `--memory '2Gi'` ,
205+ exp : [ `--memory` , `'2Gi'` ] ,
206+ } ,
207+ {
208+ name : `with equals and space and single quotes` ,
209+ input : `--memory='2Gi' --concurrency '2'` ,
210+ exp : [ `--memory` , `'2Gi'` , `--concurrency` , `'2'` ] ,
211+ } ,
212+ {
213+ name : `with equals and space and some single quotes` ,
214+ input : `--memory='2Gi' --concurrency 2` ,
215+ exp : [ `--memory` , `'2Gi'` , `--concurrency` , `2` ] ,
216+ } ,
217+ {
218+ name : `with double and single quotes` ,
219+ input : `--memory='2Gi' --concurrency="2"` ,
220+ exp : [ `--memory` , `'2Gi'` , `--concurrency` , `"2"` ] ,
221+ } ,
222+ ] ;
223+
224+ cases . forEach ( ( tc ) => {
225+ it ( tc . name , ( ) => {
226+ const result = parseFlags ( tc . input ) ;
227+ expect ( result ) . to . eql ( tc . exp ) ;
228+ } ) ;
190229 } ) ;
191230 } ) ;
192231} ) ;
0 commit comments