Skip to content

Commit

Permalink
fix: download tests & taskqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
bastiandoetsch committed Jan 8, 2024
1 parent 4615075 commit 89d266e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class SnykCliDownloaderService {
}

fun cliSilentAutoUpdate(indicator: ProgressIndicator, project: Project) {
if (isFourDaysPassedSinceLastCheck() && !ApplicationManager.getApplication().isUnitTestMode) {
if (isFourDaysPassedSinceLastCheck()) {
val latestReleaseInfo = requestLatestReleasesInformation()

indicator.checkCanceled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class SnykTaskQueueServiceTest : LightPlatformTestCase() {
"testTag"
)
every { getSnykCliDownloaderService() } returns downloaderServiceMock
every { downloaderServiceMock.isFourDaysPassedSinceLastCheck() } returns false
every { confirmScanningAndSetWorkspaceTrustedStateIfNeeded(any(), any()) } returns true
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import io.snyk.plugin.removeDummyCliFile
import io.snyk.plugin.resetSettings
import io.snyk.plugin.services.SnykApplicationSettingsStateService
import org.apache.http.HttpStatus
import org.junit.Test
import java.io.File
import java.net.SocketTimeoutException
import java.time.LocalDate
Expand Down Expand Up @@ -60,7 +59,6 @@ class CliDownloaderServiceIntegTest : LightPlatformTestCase() {
/**
* Needs an internet connection - real test if release info can be downloaded
*/
@Test
fun testGetLatestReleasesInformation() {
val latestReleaseInfo = project.service<SnykCliDownloaderService>().requestLatestReleasesInformation()

Expand All @@ -75,7 +73,6 @@ class CliDownloaderServiceIntegTest : LightPlatformTestCase() {
* Should be THE ONLY test where we actually do download the CLI
* !!! Do __MOCK__ cli download in ANY other test to reduce testing time needed !!!
*/
@Test
fun testDownloadLatestCliRelease() {
ensureCliFileExistent()

Expand All @@ -90,7 +87,6 @@ class CliDownloaderServiceIntegTest : LightPlatformTestCase() {
verify { downloader.verifyChecksum(any(), any()) }
}

@Test
fun testDownloadLatestCliReleaseFailsWhenShaDoesNotMatch() {
ensureCliFileExistent()

Expand All @@ -113,7 +109,6 @@ class CliDownloaderServiceIntegTest : LightPlatformTestCase() {
}
}

@Test
fun testDownloadLatestCliReleaseShouldHandleSocketTimeout() {
val indicator = EmptyProgressIndicator()
val exceptionMessage = "Read Timed Out"
Expand All @@ -130,7 +125,6 @@ class CliDownloaderServiceIntegTest : LightPlatformTestCase() {
}
}

@Test
fun testDownloadLatestCliReleaseShouldHandleHttpStatusException() {
val httpStatusException = HttpRequests.HttpStatusException("status bad", HttpStatus.SC_GATEWAY_TIMEOUT, "url")

Expand All @@ -145,7 +139,6 @@ class CliDownloaderServiceIntegTest : LightPlatformTestCase() {
}
}

@Test
fun testDownloadLatestCliReleaseWhenNoReleaseInfoAvailable() {
val cliDownloaderService = project.service<SnykCliDownloaderService>()

Expand All @@ -157,7 +150,6 @@ class CliDownloaderServiceIntegTest : LightPlatformTestCase() {
}
}

@Test
fun testCliSilentAutoUpdate() {
val currentDate = LocalDateTime.now()

Expand All @@ -178,7 +170,6 @@ class CliDownloaderServiceIntegTest : LightPlatformTestCase() {
)
}

@Test
fun testCliSilentAutoUpdateWhenPreviousUpdateInfoIsNull() {
val currentDate = LocalDate.now()
val settings = pluginSettings()
Expand All @@ -195,7 +186,6 @@ class CliDownloaderServiceIntegTest : LightPlatformTestCase() {
verify { cutSpy.downloadLatestRelease(any(), any()) }
}

@Test
fun testIsNewVersionAvailable() {
pluginSettings().lastCheckDate = null

Expand All @@ -212,7 +202,6 @@ class CliDownloaderServiceIntegTest : LightPlatformTestCase() {
assertFalse(cliDownloaderService.isNewVersionAvailable("1.342.2", "1.342.2"))
}

@Test
fun testCheckIsFourDaysPassedSinceLastCheck() {
val todayDate = LocalDateTime.now()
val lastCheckDate = todayDate.minusDays(4)
Expand Down

0 comments on commit 89d266e

Please sign in to comment.