Skip to content

Commit a8a1712

Browse files
committed
tst
1 parent 076a459 commit a8a1712

File tree

3 files changed

+23
-15
lines changed

3 files changed

+23
-15
lines changed

plugins/amazonq/shared/jetbrains-community/build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ dependencies {
2424

2525
testFixturesApi(testFixtures(project(":plugin-core:jetbrains-community")))
2626
}
27+
28+
// hack because our test structure currently doesn't make complete sense
29+
tasks.prepareTestSandbox {
30+
val pluginXmlJar = project(":plugin-amazonq").tasks.jar
31+
32+
dependsOn(pluginXmlJar)
33+
intoChild(intellijPlatform.projectName.map { "$it/lib" })
34+
.from(pluginXmlJar)
35+
}

plugins/amazonq/shared/jetbrains-community/tst/software/aws/toolkits/jetbrains/services/amazonq/lsp/artifacts/ArtifactManagerTest.kt

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
package software.aws.toolkits.jetbrains.services.amazonq.lsp.artifacts
55

6+
import com.intellij.ide.plugins.PluginManagerCore
7+
import com.intellij.openapi.extensions.PluginId
68
import com.intellij.testFramework.ProjectExtension
79
import com.intellij.util.text.SemVer
810
import io.mockk.Runs
@@ -51,29 +53,31 @@ class ArtifactManagerTest {
5153
}
5254

5355
@Test
54-
fun `fetch artifact fetcher throws exception if manifest is null`() = runTest {
56+
fun `fetch artifact fetcher returns bundled if manifest is null`() = runTest {
5557
every { manifestFetcher.fetch() }.returns(null)
5658

5759
val exception = assertThrows<LspException> {
5860
artifactManager.fetchArtifact(projectExtension.project)
5961
}
60-
assertThat(exception)
61-
.hasFieldOrPropertyWithValue("errorCode", LspException.ErrorCode.MANIFEST_FETCH_FAILED)
62+
63+
assertThat(artifactManager.fetchArtifact(projectExtension.project))
64+
.isEqualTo(
65+
PluginManagerCore.getPlugin(PluginId.getId("amazon.q"))?.pluginPath?.resolve("flare")
66+
)
6267
}
6368

6469
@Test
65-
fun `fetch artifact does not have any valid lsp versions`() = runTest {
70+
fun `fetch artifact does not have any valid lsp versions returns bundled`() = runTest {
6671
every { manifestFetcher.fetch() }.returns(Manifest())
6772

6873
every { artifactManager.getLSPVersionsFromManifestWithSpecifiedRange(any()) }.returns(
6974
ArtifactManager.LSPVersions(deListedVersions = emptyList(), inRangeVersions = emptyList())
7075
)
7176

72-
val exception = assertThrows<LspException> {
73-
artifactManager.fetchArtifact(projectExtension.project)
74-
}
75-
assertThat(exception)
76-
.hasFieldOrPropertyWithValue("errorCode", LspException.ErrorCode.NO_COMPATIBLE_LSP_VERSION)
77+
assertThat(artifactManager.fetchArtifact(projectExtension.project))
78+
.isEqualTo(
79+
PluginManagerCore.getPlugin(PluginId.getId("amazon.q"))?.pluginPath?.resolve("flare")
80+
)
7781
}
7882

7983
@Test

plugins/core/jetbrains-community/src/software/aws/toolkits/jetbrains/AwsToolkit.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,7 @@ data class PluginInfo(val id: String, val name: String) {
3737
val version: String?
3838
get() = descriptor?.version
3939
val path: Path?
40-
get() =
41-
if (ApplicationManager.getApplication().isUnitTestMode) {
42-
Paths.get(System.getProperty("plugin.path"))
43-
} else {
44-
descriptor?.pluginPath
45-
}
40+
get() = descriptor?.pluginPath
4641
}
4742

4843
enum class AwsPlugin {

0 commit comments

Comments
 (0)