@@ -4,9 +4,9 @@ import * as core from '@actions/core';
44import * as exec from '@actions/exec' ;
55import * as setupGcloud from '@google-github-actions/setup-cloud-sdk' ;
66import { expect } from 'chai' ;
7- import { run , parseFlags } from '../../src/main' ;
8- import { run as postRun } from '../../src/post' ;
9- import { EOL } from 'os' ;
7+ import { run } from '../../src/main' ;
8+ import { run as postRun } from '../../src/post' ;
9+ import { EOL } from 'os' ;
1010
1111import { promises as fs } from 'fs' ;
1212
@@ -36,7 +36,7 @@ const fakeInputs: { [key: string]: string } = {
3636} ;
3737
3838function getInputMock ( name : string ) : string {
39- return fakeInputs [ name ] ;
39+ return fakeInputs [ name ] ;
4040}
4141
4242describe ( '#ssh-compute' , function ( ) {
@@ -95,8 +95,9 @@ describe('#ssh-compute', function () {
9595 this . stubs . getInput . withArgs ( 'gcloud_component' ) . returns ( 'wrong_value' ) ;
9696 await run ( ) ;
9797 expect (
98- this . stubs . setFailed . withArgs ( `${ ERROR_PREFIX } invalid input received for gcloud_component: wrong_value` )
99- . callCount ,
98+ this . stubs . setFailed . withArgs (
99+ `${ ERROR_PREFIX } invalid input received for gcloud_component: wrong_value` ,
100+ ) . callCount ,
100101 ) . to . be . at . least ( 1 ) ;
101102 } ) ;
102103
@@ -117,17 +118,19 @@ describe('#ssh-compute', function () {
117118 this . stubs . getInput . withArgs ( 'command' ) . returns ( 'test command' ) ;
118119 await run ( ) ;
119120 expect (
120- this . stubs . setFailed . withArgs ( `${ ERROR_PREFIX } either \`command\` or \`script\` should be set` )
121- . callCount ,
121+ this . stubs . setFailed . withArgs (
122+ `${ ERROR_PREFIX } either \`command\` or \`script\` should be set` ,
123+ ) . callCount ,
122124 ) . to . be . at . least ( 1 ) ;
123125 } ) ;
124126
125127 it ( 'throws an error if neither script nor command is set' , async function ( ) {
126128 this . stubs . getInput . withArgs ( 'command' ) . returns ( undefined ) ;
127129 await run ( ) ;
128130 expect (
129- this . stubs . setFailed . withArgs ( `${ ERROR_PREFIX } either \`command\` or \`script\` should be set` )
130- . callCount ,
131+ this . stubs . setFailed . withArgs (
132+ `${ ERROR_PREFIX } either \`command\` or \`script\` should be set` ,
133+ ) . callCount ,
131134 ) . to . be . at . least ( 1 ) ;
132135 } ) ;
133136
@@ -173,13 +176,17 @@ describe('#ssh-compute', function () {
173176 it ( 'writes private key to the folder' , async function ( ) {
174177 this . stubs . getInput . withArgs ( 'ssh_keys_dir' ) . returns ( 'temp-dir' ) ;
175178 await run ( ) ;
176- expect ( this . stubs . writeFile . withArgs ( 'temp-dir/google_compute_engine.pub' ) . callCount ) . to . eq ( 1 ) ;
179+ expect ( this . stubs . writeFile . withArgs ( 'temp-dir/google_compute_engine.pub' ) . callCount ) . to . eq (
180+ 1 ,
181+ ) ;
177182 } ) ;
178183
179184 it ( 'writes public key to the folder' , async function ( ) {
180185 this . stubs . getInput . withArgs ( 'ssh_keys_dir' ) . returns ( 'temp-dir' ) ;
181186 await run ( ) ;
182- expect ( this . stubs . writeFile . withArgs ( 'temp-dir/google_compute_engine.pub' ) . callCount ) . to . eq ( 1 ) ;
187+ expect ( this . stubs . writeFile . withArgs ( 'temp-dir/google_compute_engine.pub' ) . callCount ) . to . eq (
188+ 1 ,
189+ ) ;
183190 } ) ;
184191
185192 it ( 'sets the correct command if script is provided' , async function ( ) {
@@ -227,76 +234,4 @@ describe('#ssh-compute', function () {
227234 expect ( this . stubs . rm . callCount ) . to . eq ( 1 ) ;
228235 } ) ;
229236 } ) ;
230-
231- describe ( '#parseFlags' , ( ) => {
232- const cases = [
233- {
234- name : `with equals` ,
235- input : `--concurrency=2 --memory=2Gi` ,
236- exp : [ `--concurrency` , `2` , `--memory` , `2Gi` ] ,
237- } ,
238- {
239- name : `with spaces` ,
240- input : `--concurrency 2 --memory 2Gi` ,
241- exp : [ `--concurrency` , `2` , `--memory` , `2Gi` ] ,
242- } ,
243- {
244- name : `with equals and spaces` ,
245- input : `--concurrency 2 --memory=2Gi` ,
246- exp : [ `--concurrency` , `2` , `--memory` , `2Gi` ] ,
247- } ,
248- {
249- name : `with equals and double quotes` ,
250- input : `--memory="2Gi"` ,
251- exp : [ `--memory` , `"2Gi"` ] ,
252- } ,
253- {
254- name : `with space and double quotes` ,
255- input : `--memory "2Gi"` ,
256- exp : [ `--memory` , `"2Gi"` ] ,
257- } ,
258- {
259- name : `with equals and space and double quotes` ,
260- input : `--memory="2Gi" --concurrency "2"` ,
261- exp : [ `--memory` , `"2Gi"` , `--concurrency` , `"2"` ] ,
262- } ,
263- {
264- name : `with equals and space and some double quotes` ,
265- input : `--memory="2Gi" --concurrency 2` ,
266- exp : [ `--memory` , `"2Gi"` , `--concurrency` , `2` ] ,
267- } ,
268- {
269- name : `with equals and single quotes` ,
270- input : `--memory='2Gi'` ,
271- exp : [ `--memory` , `'2Gi'` ] ,
272- } ,
273- {
274- name : `with space and single quotes` ,
275- input : `--memory '2Gi'` ,
276- exp : [ `--memory` , `'2Gi'` ] ,
277- } ,
278- {
279- name : `with equals and space and single quotes` ,
280- input : `--memory='2Gi' --concurrency '2'` ,
281- exp : [ `--memory` , `'2Gi'` , `--concurrency` , `'2'` ] ,
282- } ,
283- {
284- name : `with equals and space and some single quotes` ,
285- input : `--memory='2Gi' --concurrency 2` ,
286- exp : [ `--memory` , `'2Gi'` , `--concurrency` , `2` ] ,
287- } ,
288- {
289- name : `with double and single quotes` ,
290- input : `--memory='2Gi' --concurrency="2"` ,
291- exp : [ `--memory` , `'2Gi'` , `--concurrency` , `"2"` ] ,
292- } ,
293- ] ;
294-
295- cases . forEach ( ( tc ) => {
296- it ( tc . name , ( ) => {
297- const result = parseFlags ( tc . input ) ;
298- expect ( result ) . to . eql ( tc . exp ) ;
299- } ) ;
300- } ) ;
301- } ) ;
302- } ) ;
237+ } ) ;
0 commit comments