ganache test

This commit is contained in:
a10zn8
2022-11-14 14:42:36 +04:00
parent 84ac73e8fa
commit d1e05b0215
5 changed files with 171 additions and 10 deletions

View File

@@ -33,9 +33,11 @@ import org.springframework.boot.SpringApplication
import org.springframework.context.ApplicationContext
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Profile
import org.springframework.core.env.Environment
import org.springframework.scheduling.annotation.EnableAsync
import org.springframework.scheduling.annotation.EnableScheduling
import org.springframework.util.ResourceUtils
import reactor.core.scheduler.Scheduler
import reactor.core.scheduler.Schedulers
import java.io.File
@@ -47,8 +49,8 @@ import kotlin.system.exitProcess
@EnableScheduling
@EnableAsync
open class Config(
@Autowired private val env: Environment,
@Autowired private val ctx: ApplicationContext
private val env: Environment,
private val ctx: ApplicationContext
) {
companion object {
@@ -61,16 +63,20 @@ open class Config(
private var configFilePath: File? = null
init {
configFilePath = getConfigPath()
Global.version = env.getProperty("version.app", Global.version).let {
if (it.contains("SNAPSHOT")) {
listOfNotNull(it, env.getProperty("version.commit")).joinToString("-")
} else {
it
if (!env.activeProfiles.contains("test")) {
configFilePath = getConfigPath()
Global.version = env.getProperty("version.app", Global.version).let {
if (it.contains("SNAPSHOT")) {
listOfNotNull(it, env.getProperty("version.commit")).joinToString("-")
} else {
it
}
}
}
Security.addProvider(BouncyCastleProvider())
Security.addProvider(BouncyCastleProvider())
} else {
configFilePath = ResourceUtils.getFile("classpath:integration/dshackle.yaml")
}
}
fun getConfigPath(): File {
@@ -95,6 +101,7 @@ open class Config(
}
@Bean
@Profile("!test")
open fun mainConfig(@Autowired fileResolver: FileResolver): MainConfig {
val f = configFilePath ?: throw IllegalStateException("Config path is not set")
log.info("Using config: ${f.absolutePath}")