1
0
Fork 0
mirror of https://github.com/ethauvin/kobalt.git synced 2025-04-26 00:17:11 -07:00

BlockExtractorTest.

This commit is contained in:
Cedric Beust 2017-03-30 15:12:35 -07:00
parent 9f249822ba
commit 255e17d88b
2 changed files with 42 additions and 2 deletions

View file

@ -0,0 +1,35 @@
package com.beust.kobalt.internal
import com.beust.kobalt.TestModule
import com.beust.kobalt.app.BuildFiles
import org.assertj.core.api.Assertions.assertThat
import org.testng.annotations.Guice
import org.testng.annotations.Test
import java.io.File
@Guice(modules = arrayOf(TestModule::class))
class BlockExtractorTest {
@Test
fun verifyExtraction() {
val imports = listOf("import com.beust.kobalt.*", "import com . beust.kobalt.api.*")
val topLines = listOf("", "val VERSION = \"6.11.1-SNAPSHOT\"", "")
val buildScript = listOf(
"val bs = buildScript {",
" repos(\"https://dl.bintray.com/cbeust/maven\")",
"}"
)
val allLines = imports + topLines + buildScript
val be = BuildFiles.BLOCK_EXTRACTOR
val bsi = be.extractBlock(File(""), allLines)
if (bsi != null) {
assertThat(bsi.sections.size).isEqualTo(1)
assertThat(bsi.sections[0].start).isEqualTo(5)
assertThat(bsi.sections[0].end).isEqualTo(7)
assertThat(bsi.topLines).isEqualTo(topLines)
} else {
throw AssertionError("Should have found a buildScript{}")
}
}
}