Skip to content

Commit

Permalink
test(osv): Make the test for getting vulnerability IDs less flaky
Browse files Browse the repository at this point in the history
Relax the assertion to use `containsAll` instead of equality.

Signed-off-by: Frank Viernau <[email protected]>
  • Loading branch information
fviernau committed Jan 20, 2025
1 parent 718d762 commit 4bfd33f
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions clients/osv/src/funTest/kotlin/OsvServiceWrapperFunTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@
package org.ossreviewtoolkit.clients.osv

import io.kotest.core.spec.style.WordSpec
import io.kotest.matchers.collections.beEmpty
import io.kotest.matchers.collections.containAll
import io.kotest.matchers.collections.shouldContain
import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder
import io.kotest.matchers.collections.shouldHaveSize
import io.kotest.matchers.result.shouldBeSuccess
import io.kotest.matchers.should
import io.kotest.matchers.shouldBe

import java.time.Instant
Expand Down Expand Up @@ -98,21 +102,23 @@ class OsvServiceWrapperFunTest : WordSpec({
val result = OsvServiceWrapper().getVulnerabilityIdsForPackages(requests)

result.shouldBeSuccess {
it shouldBe listOf(
listOf(
"CVE-2021-45931",
"CVE-2022-33068",
"CVE-2023-25193",
"CVE-2024-56732",
"OSV-2020-484"
),
emptyList(),
listOf(
"OSV-2018-115",
"OSV-2018-143",
"OSV-2018-97",
"OSV-2020-484"
)
it shouldHaveSize 3

it[0] should containAll(
"CVE-2021-45931",
"CVE-2022-33068",
"CVE-2023-25193",
"CVE-2024-56732",
"OSV-2020-484"
)

it[1] should beEmpty()

it[2] should containAll(
"OSV-2018-115",
"OSV-2018-143",
"OSV-2018-97",
"OSV-2020-484"
)
}
}
Expand Down

0 comments on commit 4bfd33f

Please sign in to comment.