Skip to content

Commit

Permalink
test(ossindex): Simplify some result assertions
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Nov 3, 2023
1 parent 5ba8629 commit ae37645
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions advisor/src/test/kotlin/advisors/OssIndexTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ import com.github.tomakehurst.wiremock.client.WireMock.urlPathEqualTo
import com.github.tomakehurst.wiremock.core.WireMockConfiguration

import io.kotest.core.spec.style.WordSpec
import io.kotest.inspectors.forAll
import io.kotest.matchers.collections.beEmpty
import io.kotest.matchers.collections.containExactly
import io.kotest.matchers.collections.shouldHaveSize
import io.kotest.matchers.maps.beEmpty as beEmptyMap
import io.kotest.matchers.collections.shouldHaveSingleElement
import io.kotest.matchers.should
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNot

import java.net.URI

Expand Down Expand Up @@ -78,7 +77,6 @@ class OssIndexTest : WordSpec({

val result = ossIndex.retrievePackageFindings(packages).mapKeys { it.key.id }

result shouldNot beEmptyMap()
result.keys should containExactly(ID_JUNIT)
result[ID_JUNIT] shouldNotBeNull {
advisor shouldBe ossIndex.details
Expand Down Expand Up @@ -123,17 +121,11 @@ class OssIndexTest : WordSpec({

val result = ossIndex.retrievePackageFindings(packages).mapKeys { it.key.id }

result shouldNotBeNull {
keys should containExactly(COMPONENTS_REQUEST_IDS)

COMPONENTS_REQUEST_IDS.forEach { pkg ->
val pkgResult = getValue(pkg)
pkgResult.advisor shouldBe ossIndex.details
pkgResult.vulnerabilities should beEmpty()
pkgResult.summary.issues shouldHaveSize 1
val issue = pkgResult.summary.issues.first()
issue.severity shouldBe Severity.ERROR
}
result.keys shouldBe COMPONENTS_REQUEST_IDS
result.forAll { (_, advisorResult) ->
advisorResult.advisor shouldBe ossIndex.details
advisorResult.vulnerabilities should beEmpty()
advisorResult.summary.issues shouldHaveSingleElement { it.severity == Severity.ERROR }
}
}

Expand Down

0 comments on commit ae37645

Please sign in to comment.