Skip to content

Commit

Permalink
chore(dsl): Pass tests
Browse files Browse the repository at this point in the history
  • Loading branch information
boddissattva committed Apr 5, 2024
1 parent 18d7c37 commit 4d47219
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,23 +102,24 @@ private object ChutneyScenarioJSONSerializer {
private fun getJsonFile(path: String, scenario: ChutneyScenario): File? {
return File(path).walkTopDown().filter { it.isFile }
.firstOrNull {
val chutneyScenarioIdFromFileName = getChutneyScenarioIdFromFileName(it.name)
val sameId = scenario.id != null && scenario.id == chutneyScenarioIdFromFileName
val sameName = it.name.equals(scenario.fileName(), ignoreCase = true)
val idAndNameFromFileName = getChutneyScenarioIdFromFileName(it.name)
val sameId = scenario.id != null && scenario.id == idAndNameFromFileName.first
val sameName = idAndNameFromFileName.second.equals(scenario.noIdFileName(), ignoreCase = true)
sameId || sameName
}
}

private fun getChutneyScenarioIdFromFileName(fileName: String): Int? {
val dashIndex = fileName.indexOf("-")
private fun getChutneyScenarioIdFromFileName(fileName: String): Pair<Int?, String> {
val idAndName = fileName.split("-")
return try {
if (dashIndex > 0) Integer.valueOf(fileName.substring(0, dashIndex)) else null
if (idAndName.size > 1) (Integer.valueOf(idAndName[0]) to idAndName[1]) else (null to idAndName[0])
} catch (e: Exception) {
null
null to ""
}
}

private fun ChutneyScenario.fileName() = (id?.let { "$id-" } ?: "") + title + ".chutney.json"
private fun ChutneyScenario.fileName() = (id?.let { "$id-" } ?: "") + this.noIdFileName()
private fun ChutneyScenario.noIdFileName() = "$title.chutney.json"

private fun updateJsonFile(file: File, scenario: ChutneyScenario) {
file.writeText(scenario.toString())
Expand Down
3 changes: 2 additions & 1 deletion kotlin-dsl/dsl/src/test/kotlin/blackbox/IntegrationTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import org.testcontainers.junit.jupiter.Testcontainers
import util.WSLUtil
import java.io.File
import java.nio.file.Files
import java.time.Duration

@Testcontainers
class IntegrationTest {
Expand All @@ -35,7 +36,7 @@ class IntegrationTest {
// Start server
chutneyServer = GenericContainer<Nothing>("ghcr.io/chutney-testing/chutney/server:latest")
.apply {
//withStartupTimeout(Duration.ofSeconds(30))
withStartupTimeout(Duration.ofSeconds(80))
withExposedPorts(8443)
withFileSystemBind(WSLUtil.wslPath(tempDirectory), "/config", BindMode.READ_WRITE)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import org.testcontainers.containers.Network
import org.testcontainers.images.PullPolicy
import org.testcontainers.junit.jupiter.Testcontainers
import org.testcontainers.utility.DockerImageName
import java.time.Duration

@Testcontainers
class SeleniumTest {
Expand All @@ -23,6 +24,7 @@ class SeleniumTest {
.withNetworkAliases("chutneyServer")
.withExposedPorts(8443)
.withNetwork(network)
.withStartupTimeout(Duration.ofSeconds(80))

val webDriverContainer = BrowserWebDriverContainer()
.withCapabilities(FirefoxOptions().setAcceptInsecureCerts(true))
Expand Down

0 comments on commit 4d47219

Please sign in to comment.