Skip to content

Commit

Permalink
Hotfix for ID of test suites on tests (#1157)
Browse files Browse the repository at this point in the history
  • Loading branch information
nulls authored Sep 5, 2022
1 parent 0cd2e5c commit 75266f0
Showing 1 changed file with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,19 +195,34 @@ class TestDiscoveringService(
) = getAllTests(rootTestConfig, testSuites).convertToMap().updatePluginNames()

@Suppress("TYPE_ALIAS")
private fun Mono<Map<TestSuiteDto, List<TestDto>>>.saveTestSuitesAndTests() = zipWhen {
private fun Mono<Map<TestSuiteDto, List<TestDto>>>.saveTestSuitesAndTests() = flatMap {
it.saveTestSuites()
}.flatMap { (testsMap, testSuites) ->
testsMap.saveTests().thenJust(testSuites)
}.map { testsMap ->
testsMap.mapValues { (testSuite, tests) ->
tests.map { it.copy(testSuiteId = testSuite.requiredId()) }
}
}.flatMap { testsMaps ->
testsMaps.values
.flatten()
.toFlux()
.save()
.thenJust(testsMaps.keys.toList())
}

@Suppress("TYPE_ALIAS")
private fun Map<TestSuiteDto, List<TestDto>>.saveTestSuites() = keys.toList().save()
private fun Map<TestSuiteDto, List<TestDto>>.saveTestSuites() = entries
.toFlux()
.flatMap { (testSuiteDto, tests) ->
listOf(testSuiteDto).save().map { it.first() to tests }
}
.collectList()
.map { it.toMap() }

@Suppress("TYPE_ALIAS")
private fun Map<TestSuiteDto, List<TestDto>>.saveTests() = values.flatten()
.toFlux()
.save()
private fun Map<TestSuiteDto, List<TestDto>>.saveTests() =
values.flatten()
.toFlux()
.save()

@Suppress("TYPE_ALIAS")
private fun Sequence<Pair<TestSuiteDto, TestDto>>.convertToMap() = groupBy({ (testSuite, _) ->
Expand Down

0 comments on commit 75266f0

Please sign in to comment.