Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class ArtifactHelper(private val lspArtifactsPath: Path = DEFAULT_ARTIFACT_PATH,
return localFolders
.mapNotNull { localFolder ->
SemVer.parseFromText(localFolder.fileName.toString())?.let { semVer ->
if (semVer in manifestVersionRanges.startVersion..manifestVersionRanges.endVersion) {
if (semVer >= manifestVersionRanges.startVersion && semVer < manifestVersionRanges.endVersion) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (semVer >= manifestVersionRanges.startVersion && semVer < manifestVersionRanges.endVersion) {
if (semVer in manifestVersionRanges.startVersion..<manifestVersionRanges.endVersion) {

also works

localFolder to semVer
} else {
null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class ArtifactManager @NonInjectable internal constructor(private val manifestFe
SemVer.parseFromText(serverVersion)?.let { semVer ->
when {
version.isDelisted != false -> Pair(version, true) // Is deListed
semVer in DEFAULT_VERSION_RANGE.let { it.startVersion..it.endVersion } -> Pair(version, false) // Is in range
(semVer >= DEFAULT_VERSION_RANGE.startVersion && semVer < DEFAULT_VERSION_RANGE.endVersion) -> Pair(version, false) // Is in range
else -> null
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ class ArtifactHelperTest {
tempDir.resolve("1.0.0").createDirectories()
tempDir.resolve("1.0.1").createDirectories()
tempDir.resolve("1.0.2").createDirectories()

manifestVersionRanges = SupportedManifestVersionRange(
startVersion = SemVer("1.0.0", 1, 0, 0),
endVersion = SemVer("2.0.0", 2, 0, 0)
Expand All @@ -112,6 +113,21 @@ class ArtifactHelperTest {
assertThat(actualResult.first().first.fileName.toString()).isEqualTo("1.0.2")
}

@Test
fun `getAllLocalLspArtifactsWithinManifestRange does not return end major version path`() {
tempDir.resolve("1.0.0").createDirectories()
tempDir.resolve("2.0.0").createDirectories()
manifestVersionRanges = SupportedManifestVersionRange(
startVersion = SemVer("1.0.0", 1, 0, 0),
endVersion = SemVer("2.0.0", 2, 0, 0)
)

val actualResult = artifactHelper.getAllLocalLspArtifactsWithinManifestRange(manifestVersionRanges)
assertThat(actualResult).isNotNull()
assertThat(actualResult.size).isEqualTo(1)
assertThat(actualResult.first().first.fileName.toString()).isNotEqualTo("2.0.0")
}

@Test
fun `getExistingLspArtifacts should find all the artifacts`() {
val version1Dir = tempDir.resolve("1.0.0").apply { toFile().mkdirs() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ class ArtifactManagerTest {
.hasFieldOrPropertyWithValue("errorCode", LspException.ErrorCode.NO_COMPATIBLE_LSP_VERSION)
}

@Test
fun `getLSPVersionsFromManifestWithSpecifiedRange excludes end major version`() = runTest {
val newManifest = Manifest(versions = listOf(Version(serverVersion = "2.0.0")))
val result = artifactManager.getLSPVersionsFromManifestWithSpecifiedRange(newManifest)
assertThat(result.inRangeVersions).isEmpty()
}

@Test
fun `fetch artifact if inRangeVersions are not available should fallback to local lsp`() = runTest {
val expectedResult = listOf(Pair(tempDir, SemVer("1.0.0", 1, 0, 0)))
Expand Down
Loading