File tree 2 files changed +13
-14
lines changed
main/kotlin/com/coder/gateway
test/kotlin/com/coder/gateway/util
2 files changed +13
-14
lines changed Original file line number Diff line number Diff line change @@ -413,10 +413,9 @@ class CoderRemoteConnectionHandle {
413
413
) {
414
414
if (setupCommand.isNotBlank()) {
415
415
indicator.text = " Running setup command..."
416
- processSetupCommand(
417
- { exec(workspace, setupCommand) },
418
- ignoreSetupFailure
419
- )
416
+ processSetupCommand(ignoreSetupFailure) {
417
+ exec(workspace, setupCommand)
418
+ }
420
419
} else {
421
420
logger.info(" No setup command to run on ${workspace.hostname} " )
422
421
}
@@ -523,11 +522,11 @@ class CoderRemoteConnectionHandle {
523
522
companion object {
524
523
val logger = Logger .getInstance(CoderRemoteConnectionHandle ::class .java.simpleName)
525
524
fun processSetupCommand (
526
- output : () -> String ,
527
- ignoreSetupFailure : Boolean
525
+ ignoreSetupFailure : Boolean ,
526
+ execCommand : () -> String
528
527
) {
529
528
try {
530
- val errorText = output
529
+ val errorText = execCommand
531
530
.invoke()
532
531
.lines()
533
532
.firstOrNull { it.contains(GATEWAY_SETUP_COMMAND_ERROR ) }
Original file line number Diff line number Diff line change @@ -12,36 +12,36 @@ internal class SetupCommandTest {
12
12
assertEquals(
13
13
" Execution error" ,
14
14
assertThrows<Exception > {
15
- processSetupCommand({ throw Exception (" Execution error" ) }, false )
15
+ processSetupCommand(false ) { throw Exception (" Execution error" ) }
16
16
}.message
17
17
)
18
- processSetupCommand({ throw Exception (" Execution error" ) }, true )
18
+ processSetupCommand(true ) { throw Exception (" Execution error" ) }
19
19
}
20
20
21
21
@Test
22
22
fun setupScriptError () {
23
23
assertEquals(
24
24
" Your IDE is expired, please update" ,
25
25
assertThrows<Exception > {
26
- processSetupCommand({
27
- """
26
+ processSetupCommand(false ) {
27
+ """
28
28
execution line 1
29
29
execution line 2
30
30
CODER_SETUP_ERRORYour IDE is expired, please update
31
31
execution line 3
32
32
"""
33
- }, false )
33
+ }
34
34
}.message
35
35
)
36
36
37
- processSetupCommand({
37
+ processSetupCommand(true ) {
38
38
"""
39
39
execution line 1
40
40
execution line 2
41
41
CODER_SETUP_ERRORYour IDE is expired, please update
42
42
execution line 3
43
43
"""
44
- }, true )
44
+ }
45
45
46
46
}
47
47
}
You can’t perform that action at this time.
0 commit comments