@@ -148,13 +148,14 @@ describe('force:apex:execute', () => {
148148 test
149149 . withOrg ( { username : 'test@org.com' } , true )
150150 . withConnectionRequest ( ( ) => Promise . resolve ( soapCompileProblem ) )
151- . stub ( ExecuteService . prototype , 'getUserInput' , ( ) => 'System.assert(true) ' )
151+ . stub ( ExecuteService . prototype , 'getUserInput' , ( ) => 'ThisStatementShouldntCompile ' )
152152 . stub ( ExecuteService . prototype , 'buildExecRequest' , ( ) => {
153153 'fakeData' ;
154154 } )
155155 . stdout ( )
156156 . command ( [ 'force:apex:execute' , '--targetusername' , 'test@org.com' , '--json' ] )
157157 . it ( 'runs default command with json flag and compile problem' , ( ctx ) => {
158+ expect ( process . exitCode ) . to . eql ( 1 ) ;
158159 const result = ctx . stdout ;
159160 expect ( result ) . to . not . be . empty ;
160161 const resultJSON = JSON . parse ( result ) ;
@@ -165,7 +166,7 @@ describe('force:apex:execute', () => {
165166 test
166167 . withOrg ( { username : 'test@org.com' } , true )
167168 . withConnectionRequest ( ( ) => Promise . resolve ( soapResponse ) )
168- . stub ( ExecuteService . prototype , 'getUserInput' , ( ) => 'System.assert(true)' )
169+ . stub ( ExecuteService . prototype , 'getUserInput' , ( ) => 'System.assert(true); ' )
169170 . stub ( ExecuteService . prototype , 'buildExecRequest' , ( ) => {
170171 'fakeData' ;
171172 } )
@@ -180,13 +181,16 @@ describe('force:apex:execute', () => {
180181 test
181182 . withOrg ( { username : 'test@org.com' } , true )
182183 . withConnectionRequest ( ( ) => Promise . resolve ( soapCompileProblem ) )
183- . stub ( ExecuteService . prototype , 'getUserInput' , ( ) => 'System.assert(true) ' )
184+ . stub ( ExecuteService . prototype , 'getUserInput' , ( ) => 'ThisStatementShouldntCompile ' )
184185 . stub ( ExecuteService . prototype , 'buildExecRequest' , ( ) => {
185186 'fakeData' ;
186187 } )
187188 . stdout ( )
189+ . stderr ( )
188190 . command ( [ 'force:apex:execute' , '--targetusername' , 'test@org.com' ] )
189191 . it ( 'runs default command with compile issue in human readable output' , ( ctx ) => {
192+ expect ( process . exitCode ) . to . eql ( 1 ) ;
193+ expect ( ctx . stderr ) . to . contain ( 'Compilation failed.' ) ;
190194 const result = ctx . stdout ;
191195 expect ( result ) . to . not . be . empty ;
192196 expect ( result ) . to . eql ( compileResponse ) ;
@@ -195,13 +199,16 @@ describe('force:apex:execute', () => {
195199 test
196200 . withOrg ( { username : 'test@org.com' } , true )
197201 . withConnectionRequest ( ( ) => Promise . resolve ( soapRuntimeProblem ) )
198- . stub ( ExecuteService . prototype , 'getUserInput' , ( ) => 'System.assert(true) ' )
202+ . stub ( ExecuteService . prototype , 'getUserInput' , ( ) => 'System.assert(false); ' )
199203 . stub ( ExecuteService . prototype , 'buildExecRequest' , ( ) => {
200204 'fakeData' ;
201205 } )
202206 . stdout ( )
207+ . stderr ( )
203208 . command ( [ 'force:apex:execute' , '--targetusername' , 'test@org.com' ] )
204209 . it ( 'runs default command with runtime issue in human readable output' , ( ctx ) => {
210+ expect ( process . exitCode ) . to . eql ( 1 ) ;
211+ expect ( ctx . stderr ) . to . contain ( 'Execution failed.' ) ;
205212 const result = ctx . stdout ;
206213 expect ( result ) . to . not . be . empty ;
207214 expect ( result ) . to . eql ( runtimeResponse ) ;
0 commit comments