Skip to content

Commit

Permalink
Coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Jul 2, 2024
1 parent 5c92a76 commit d279b27
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ object VyperCompiler {
private const val COMPILATION_EMPTY = "Compilation empty"
private const val COMPILATION_SUCCESS = "Compilation succeed"

fun compile(params: VyperParameters, indicator: ProgressIndicator?) =
fun compile(params: VyperParameters, indicator: ProgressIndicator? = null) =
try {
params.files.map {
val compiler =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ private class VyperFrameStreamAdapter : ResultCallback.Adapter<Frame>() {
}
}

private class VyperPullImageAdapter(private val indicator: ProgressIndicator?) :
ResultCallback.Adapter<PullResponseItem>() {
private class VyperPullImageAdapter(private val indicator: ProgressIndicator?) : ResultCallback.Adapter<PullResponseItem>() {
/**
* Map of layer id to the `current` and `total` progress of that layer.
* As the layers get known, the total progress can go backwards a bit, but it's still quite helpful to have.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import io.mockk.mockk
import org.vyperlang.plugin.annotators.CompilerAnnotator
import org.vyperlang.plugin.annotators.CompilerError
import org.vyperlang.plugin.annotators.FileInfo
import kotlin.math.pow

data class ExpectedError(val message: String, val range: Pair<Int, Int>, val tooltip: String="")

Expand Down Expand Up @@ -90,6 +89,6 @@ class TestCompilerAnnotator : BasePlatformTestCase() {

private fun fileInfo(fileName: String): FileInfo {
val file = LocalFileSystem.getInstance().findFileByPath("${testDataPath}/$fileName")!!
return FileInfo(project, file)
return FileInfo(project, file, mockk(relaxed = true))
}
}
11 changes: 11 additions & 0 deletions src/test/kotlin/org/vyperlang/plugin/parser/TestVyperCompiler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.wm.RegisterToolWindowTask
import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import io.mockk.every
import io.mockk.mockk
import org.junit.Assert.assertTrue
import org.vyperlang.plugin.VyperIcons
import org.vyperlang.plugin.compile.VyperCompiler
import org.vyperlang.plugin.compile.VyperParameters
import org.vyperlang.plugin.docker.CompilerMissingError
import org.vyperlang.plugin.docker.StatusDocker
import org.vyperlang.plugin.docker.ToolResult
import org.vyperlang.plugin.settings.VyperSettings
Expand All @@ -28,6 +31,14 @@ class TestVyperCompiler : BasePlatformTestCase() {
)
}

fun testMissingDocker() {
val params = mockk<VyperParameters> {
every { files } throws CompilerMissingError(Exception("Docker is not installed"))
every { project } returns myFixture.project
}
assertNull(VyperCompiler.compile(params))
}

fun testCompile() {
val result = compile("example.vy")
assertEmpty(result.stderr)
Expand Down

0 comments on commit d279b27

Please sign in to comment.