File tree Expand file tree Collapse file tree 2 files changed +13
-14
lines changed
main/kotlin/com/coder/gateway
test/kotlin/com/coder/gateway/util Expand file tree Collapse file tree 2 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -413,10 +413,9 @@ class CoderRemoteConnectionHandle {
413413 ) {
414414 if (setupCommand.isNotBlank()) {
415415 indicator.text = " Running setup command..."
416- processSetupCommand(
417- { exec(workspace, setupCommand) },
418- ignoreSetupFailure
419- )
416+ processSetupCommand(ignoreSetupFailure) {
417+ exec(workspace, setupCommand)
418+ }
420419 } else {
421420 logger.info(" No setup command to run on ${workspace.hostname} " )
422421 }
@@ -523,11 +522,11 @@ class CoderRemoteConnectionHandle {
523522 companion object {
524523 val logger = Logger .getInstance(CoderRemoteConnectionHandle ::class .java.simpleName)
525524 fun processSetupCommand (
526- output : () -> String ,
527- ignoreSetupFailure : Boolean
525+ ignoreSetupFailure : Boolean ,
526+ execCommand : () -> String
528527 ) {
529528 try {
530- val errorText = output
529+ val errorText = execCommand
531530 .invoke()
532531 .lines()
533532 .firstOrNull { it.contains(GATEWAY_SETUP_COMMAND_ERROR ) }
Original file line number Diff line number Diff line change @@ -12,36 +12,36 @@ internal class SetupCommandTest {
1212 assertEquals(
1313 " Execution error" ,
1414 assertThrows<Exception > {
15- processSetupCommand({ throw Exception (" Execution error" ) }, false )
15+ processSetupCommand(false ) { throw Exception (" Execution error" ) }
1616 }.message
1717 )
18- processSetupCommand({ throw Exception (" Execution error" ) }, true )
18+ processSetupCommand(true ) { throw Exception (" Execution error" ) }
1919 }
2020
2121 @Test
2222 fun setupScriptError () {
2323 assertEquals(
2424 " Your IDE is expired, please update" ,
2525 assertThrows<Exception > {
26- processSetupCommand({
27- """
26+ processSetupCommand(false ) {
27+ """
2828 execution line 1
2929 execution line 2
3030 CODER_SETUP_ERRORYour IDE is expired, please update
3131 execution line 3
3232 """
33- }, false )
33+ }
3434 }.message
3535 )
3636
37- processSetupCommand({
37+ processSetupCommand(true ) {
3838 """
3939 execution line 1
4040 execution line 2
4141 CODER_SETUP_ERRORYour IDE is expired, please update
4242 execution line 3
4343 """
44- }, true )
44+ }
4545
4646 }
4747}
You can’t perform that action at this time.
0 commit comments