add test-library and ktlint
This commit is contained in:
@@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
plugins {
|
||||
id("org.springframework.boot") version "3.3.4"
|
||||
id("io.spring.dependency-management") version "1.1.6"
|
||||
id("org.jlleitschuh.gradle.ktlint") version "12.1.1"
|
||||
kotlin("jvm") version "1.9.25"
|
||||
kotlin("plugin.spring") version "1.9.25"
|
||||
}
|
||||
@@ -26,6 +27,22 @@ dependencies {
|
||||
implementation("info.picocli:picocli-spring-boot-starter:4.7.6")
|
||||
|
||||
testImplementation("org.springframework.boot:spring-boot-starter-test")
|
||||
|
||||
// Kotest
|
||||
testImplementation("io.kotest:kotest-runner-junit5:5.9.1")
|
||||
testImplementation("io.kotest:kotest-assertions-core:5.9.1")
|
||||
testImplementation("io.kotest.extensions:kotest-extensions-spring:1.3.0")
|
||||
|
||||
// MockK
|
||||
testImplementation("io.mockk:mockk:1.13.11")
|
||||
testImplementation("com.ninja-squad:springmockk:4.0.2")
|
||||
|
||||
// WireMock
|
||||
testImplementation("org.wiremock.integrations:wiremock-spring-boot:3.1.0")
|
||||
|
||||
// Testcontainers (versions managed by Spring Boot BOM)
|
||||
testImplementation("org.springframework.boot:spring-boot-testcontainers")
|
||||
testImplementation("org.testcontainers:testcontainers")
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
|
||||
@@ -1,22 +1,32 @@
|
||||
package de.hoennig.gittally
|
||||
|
||||
import org.springframework.boot.CommandLineRunner
|
||||
import org.springframework.boot.ExitCodeGenerator
|
||||
import org.springframework.boot.SpringApplication
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
import org.springframework.boot.runApplication
|
||||
import org.springframework.stereotype.Component
|
||||
import picocli.CommandLine
|
||||
import picocli.CommandLine.IFactory
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
@SpringBootApplication
|
||||
class GitTallyApplication(
|
||||
class GitTallyApplication
|
||||
|
||||
@Component
|
||||
class CliRunner(
|
||||
private val factory: IFactory,
|
||||
private val rootCommand: GitTallyCommand,
|
||||
) : CommandLineRunner {
|
||||
) : CommandLineRunner, ExitCodeGenerator {
|
||||
private var exitCode = 0
|
||||
|
||||
override fun run(vararg args: String) {
|
||||
exitProcess(CommandLine(rootCommand, factory).execute(*args))
|
||||
exitCode = CommandLine(rootCommand, factory).execute(*args)
|
||||
}
|
||||
|
||||
override fun getExitCode() = exitCode
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
runApplication<GitTallyApplication>(*args)
|
||||
exitProcess(SpringApplication.exit(runApplication<GitTallyApplication>(*args)))
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import picocli.CommandLine.Option
|
||||
mixinStandardHelpOptions = true,
|
||||
)
|
||||
class ConfigPrintCommand : Runnable {
|
||||
|
||||
@Option(names = ["--full"], description = ["Include all defaults"])
|
||||
var full: Boolean = false
|
||||
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package de.hoennig.gittally
|
||||
|
||||
import de.hoennig.gittally.commands.ConfigPrintCommand
|
||||
import de.hoennig.gittally.commands.InitCommand
|
||||
import de.hoennig.gittally.commands.ServerCommand
|
||||
import io.kotest.core.spec.style.FunSpec
|
||||
import io.kotest.matchers.shouldNotBe
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
|
||||
@SpringBootTest
|
||||
class ApplicationContextTest : FunSpec() {
|
||||
@Autowired
|
||||
lateinit var rootCommand: GitTallyCommand
|
||||
|
||||
@Autowired
|
||||
lateinit var initCommand: InitCommand
|
||||
|
||||
@Autowired
|
||||
lateinit var serverCommand: ServerCommand
|
||||
|
||||
@Autowired
|
||||
lateinit var configPrintCommand: ConfigPrintCommand
|
||||
|
||||
init {
|
||||
test("application context loads") {
|
||||
rootCommand shouldNotBe null
|
||||
}
|
||||
|
||||
test("all subcommands are wired") {
|
||||
initCommand shouldNotBe null
|
||||
serverCommand shouldNotBe null
|
||||
configPrintCommand shouldNotBe null
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package de.hoennig.gittally
|
||||
|
||||
import io.kotest.core.config.AbstractProjectConfig
|
||||
import io.kotest.extensions.spring.SpringExtension
|
||||
|
||||
object KotestProjectConfig : AbstractProjectConfig() {
|
||||
override fun extensions() = listOf(SpringExtension)
|
||||
}
|
||||
Reference in New Issue
Block a user