Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiandoetsch committed Feb 7, 2024
1 parent 3bc91e7 commit 98dc9b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/kotlin/snyk/common/lsp/LanguageServerWrapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ class LanguageServerWrapper(
}

companion object {
private val INSTANCE = LanguageServerWrapper(executorService = Executors.newCachedThreadPool())
fun getInstance() = INSTANCE
private var INSTANCE: LanguageServerWrapper? = null
fun getInstance() = INSTANCE ?: LanguageServerWrapper().also { INSTANCE = it }
}
}
1 change: 1 addition & 0 deletions src/test/java/snyk/common/lsp/LanguageServerWrapperTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class LanguageServerWrapperTest {
val processMock = mockk<Process>(relaxed = true)
cut.process = processMock
every { processMock.info().startInstant().isPresent } returns true
every { processMock.isAlive } returns true
every {
lsMock.workspaceService.executeCommand(any<ExecuteCommandParams>())
} returns CompletableFuture.completedFuture(null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import com.intellij.util.io.HttpRequests
import io.mockk.every
import io.mockk.justRun
import io.mockk.mockk
import io.mockk.mockkObject
import io.mockk.mockkStatic
import io.mockk.spyk
import io.mockk.unmockkAll
Expand All @@ -18,6 +19,7 @@ import io.snyk.plugin.removeDummyCliFile
import io.snyk.plugin.resetSettings
import io.snyk.plugin.services.SnykApplicationSettingsStateService
import org.apache.http.HttpStatus
import snyk.common.lsp.LanguageServerWrapper
import java.io.File
import java.net.SocketTimeoutException
import java.time.LocalDate
Expand All @@ -37,6 +39,8 @@ class CliDownloaderServiceIntegTest : LightPlatformTestCase() {
unmockkAll()
resetSettings(project)
mockkStatic("io.snyk.plugin.UtilsKt")
mockkObject(LanguageServerWrapper.Companion)
every { LanguageServerWrapper.getInstance() } returns mockk(relaxed = true)
every { pluginSettings() } returns SnykApplicationSettingsStateService()
cliFile = getCliFile()
cut = project.service()
Expand Down

0 comments on commit 98dc9b2

Please sign in to comment.