forked from detekt/detekt
/
GeneratorSpec.kt
52 lines (45 loc) · 1.53 KB
/
GeneratorSpec.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package io.gitlab.arturbosch.detekt.generator.printer
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.AfterAll
import org.junit.jupiter.api.BeforeAll
import org.junit.jupiter.api.Test
import java.io.File
import java.nio.file.Files
import java.nio.file.Paths
class GeneratorSpec {
@Test
fun `config files generated successfully`() {
assertThat(File("$folder1$configPath")).exists()
assertThat(File("$folder2$configPath")).exists()
}
@Test
fun `config files have proper content`() {
assertThat(File("$folder1$configPath").readText())
.contains("complexity:")
.doesNotContain("coroutines:")
assertThat(File("$folder2$configPath").readText())
.contains("coroutines:")
.doesNotContain("complexity:")
}
companion object {
private const val folder1 = "../detekt-rules-complexity"
private const val folder2 = "../detekt-rules-coroutines"
private const val configPath = "/src/main/resources/config/config.yml"
@JvmStatic
@BeforeAll
fun init() {
val args = arrayOf(
"--generate-custom-rule-config",
"--input",
"$folder1, $folder2",
)
io.gitlab.arturbosch.detekt.generator.main(args)
}
@JvmStatic
@AfterAll
fun tearDown() {
Files.deleteIfExists(Paths.get(folder1, configPath))
Files.deleteIfExists(Paths.get(folder2, configPath))
}
}
}