Skip to content

Commit

Permalink
Merge pull request #1446 from znsio/ignore_non_json_examples_for_tests
Browse files Browse the repository at this point in the history
Ignore the files with non-json extensions in examples directory for tests
  • Loading branch information
harikrishnan83 authored Nov 25, 2024
2 parents 8e692e1 + 141ca1d commit 0369a23
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions core/src/main/kotlin/io/specmatic/core/Feature.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1641,19 +1641,20 @@ data class Feature(
if (!testsDirectory.exists())
return emptyMap()

val files = testsDirectory.listFiles()
val files = testsDirectory.walk().filterNot { it.isDirectory }.filter {
it.extension == "json"
}.toList()

if (files.isNullOrEmpty())
return emptyMap()
if (files.isEmpty()) return emptyMap()

val examlesInSubdirectories: Map<OpenApiSpecification.OperationIdentifier, List<Row>> =
val examplesInSubdirectories: Map<OpenApiSpecification.OperationIdentifier, List<Row>> =
files.filter {
it.isDirectory
}.fold(emptyMap()) { acc, item ->
acc + loadExternalisedJSONExamples(item)
}

return examlesInSubdirectories + files.filterNot { it.isDirectory }.map { ExampleFromFile(it) }.mapNotNull { exampleFromFile ->
return examplesInSubdirectories + files.filterNot { it.isDirectory }.map { ExampleFromFile(it) }.mapNotNull { exampleFromFile ->
try {
with(exampleFromFile) {
OpenApiSpecification.OperationIdentifier(
Expand Down

0 comments on commit 0369a23

Please sign in to comment.