Skip to content

Commit 156f860

Browse files
authored
Fix Go tests (#3107)
1 parent 83c3df9 commit 156f860

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

jetbrains-core/src/software/aws/toolkits/jetbrains/services/lambda/steps/SamRunnerStep.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package software.aws.toolkits.jetbrains.services.lambda.steps
66
import com.intellij.execution.configurations.GeneralCommandLine
77
import com.intellij.execution.process.ProcessHandler
88
import com.intellij.execution.runners.ExecutionEnvironment
9+
import com.intellij.openapi.application.ApplicationManager
910
import com.intellij.openapi.util.io.FileUtil
1011
import software.aws.toolkits.core.credentials.toEnvironmentVariables
1112
import software.aws.toolkits.core.utils.AttributeBagKey
@@ -32,6 +33,10 @@ class SamRunnerStep(val environment: ExecutionEnvironment, val settings: LocalLa
3233
.withParameters("local")
3334
.withParameters("invoke")
3435
.apply {
36+
if (ApplicationManager.getApplication().isUnitTestMode) {
37+
withParameters("--debug")
38+
}
39+
3540
if (settings is TemplateSettings) {
3641
withParameters(settings.logicalId)
3742
}

jetbrains-ultimate/it/software/aws/toolkits/jetbrains/services/lambda/go/GoLocalRunConfigurationIntegrationTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ class GoLocalRunConfigurationIntegrationTest(private val runtime: LambdaRuntime)
272272
fun samIsExecutedImage(): Unit = samImageRunDebugTest(
273273
projectRule = projectRule,
274274
relativePath = "samProjects/image/$runtime",
275-
templatePatches = mapOf("[GoVersion]" to (compatibleGoForIde() ?: "1")),
275+
templatePatches = mapOf("[GoVersion]" to (compatibleGoForIde())),
276276
sourceFileName = "main.go",
277277
runtime = runtime,
278278
mockCredentialsId = mockId,
@@ -285,7 +285,7 @@ class GoLocalRunConfigurationIntegrationTest(private val runtime: LambdaRuntime)
285285
samImageRunDebugTest(
286286
projectRule = projectRule,
287287
relativePath = "samProjects/image/$runtime",
288-
templatePatches = mapOf("[GoVersion]" to (compatibleGoForIde() ?: "1")),
288+
templatePatches = mapOf("[GoVersion]" to (compatibleGoForIde())),
289289
sourceFileName = "main.go",
290290
runtime = runtime,
291291
mockCredentialsId = mockId,

jetbrains-ultimate/tst/software/aws/toolkits/jetbrains/utils/rules/GoCodeInsightTestFixtureRule.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,13 @@ fun runGoModTidy(goModFile: VirtualFile) {
100100
}
101101
}
102102

103-
fun compatibleGoForIde() = when (ApplicationInfo.getInstance().build.baselineVersion) {
104-
211 -> "1.16.6" // TODO: FIX_WHEN_MIN_IS_212
105-
else -> null
103+
fun compatibleGoForIde(): String {
104+
val baseline = ApplicationInfo.getInstance().build.baselineVersion
105+
return when {
106+
baseline == 211 -> "1.16.6" // TODO: FIX_WHEN_MIN_IS_212
107+
baseline < 221 -> "1.17.8" // TODO: FIX_WHEN_MIN_IS_221
108+
else -> "1.18.0"
109+
}
106110
}
107111

108112
fun CodeInsightTestFixture.ensureCorrectGoVersion(disposable: Disposable) {
@@ -116,7 +120,7 @@ fun CodeInsightTestFixture.ensureCorrectGoVersion(disposable: Disposable) {
116120
}
117121

118122
val goVersionOverride = compatibleGoForIde()
119-
goVersionOverride?.let {
123+
goVersionOverride.let {
120124
val overrideLocation = this.tempDirPath
121125

122126
installGoSdk(overrideLocation, it)

0 commit comments

Comments
 (0)