Skip to content

Commit

Permalink
Exit if config file is not found while creating stub
Browse files Browse the repository at this point in the history
  • Loading branch information
yogeshnikam671 authored and harikrishnan83 committed Jun 13, 2024
1 parent 0b83127 commit 520df57
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/main/kotlin/in/specmatic/stub/api.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import `in`.specmatic.core.log.consoleLog
import `in`.specmatic.core.log.logger
import `in`.specmatic.core.utilities.ContractPathData
import `in`.specmatic.core.utilities.contractStubPaths
import `in`.specmatic.core.utilities.exitIfDoesNotExist
import `in`.specmatic.core.value.StringValue
import `in`.specmatic.mock.NoMatchingScenario
import `in`.specmatic.mock.ScenarioStub
Expand Down Expand Up @@ -80,7 +81,9 @@ internal fun createStub(
port: Int = 9000,
timeoutMillis: Long
): ContractStub {
// TODO - see if these two can be extracted out.
val configFileName = getConfigFileName()
exitIfDoesNotExist("config file", configFileName)
val contractPathData = contractStubPaths(configFileName)
val contractInfo = loadContractStubsFromFiles(contractPathData, dataDirPaths)
val features = contractInfo.map { it.first }
Expand All @@ -99,7 +102,10 @@ internal fun createStub(

internal fun createStub(host: String = "localhost", port: Int = 9000, timeoutMillis: Long): ContractStub {
val workingDirectory = WorkingDirectory()
// TODO - see if these two can be extracted out.
val configFileName = getConfigFileName()
exitIfDoesNotExist("config file", configFileName)

val stubs = loadContractStubsFromImplicitPaths(contractStubPaths(configFileName))
val features = stubs.map { it.first }
val expectations = contractInfoToHttpExpectations(stubs)
Expand Down

0 comments on commit 520df57

Please sign in to comment.