Skip to content

Commit

Permalink
test(model): Assert multiple assertions in a test case softly
Browse files Browse the repository at this point in the history
Do not throw already on the first assertion failure.

Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Feb 26, 2024
1 parent bbd71db commit 320bb7c
Showing 1 changed file with 24 additions and 21 deletions.
45 changes: 24 additions & 21 deletions model/src/test/kotlin/utils/FindingsMatcherTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.ossreviewtoolkit.model.utils

import io.kotest.assertions.assertSoftly
import io.kotest.core.spec.IsolationMode
import io.kotest.core.spec.style.WordSpec
import io.kotest.matchers.collections.beEmpty
Expand Down Expand Up @@ -290,27 +291,29 @@ class FindingsMatcherTest : WordSpec() {
}

"associate licenses and exceptions from the same expression" {
associateLicensesWithExceptions(
"MIT OR (GPL-2.0-only AND CC-BY-3.0 AND GCC-exception-2.0)".toSpdx()
) shouldBe "MIT OR (GPL-2.0-only WITH GCC-exception-2.0 AND CC-BY-3.0)".toSpdx()

associateLicensesWithExceptions(
"MIT OR (0BSD AND CC-BY-3.0 AND GCC-exception-2.0)".toSpdx()
) shouldBe "MIT OR (0BSD AND CC-BY-3.0 AND NOASSERTION WITH GCC-exception-2.0)".toSpdx()

associateLicensesWithExceptions(
"(BSD-3-Clause AND GPL-2.0-only WITH GCC-exception-2.0) AND (GPL-2.0-only AND GCC-exception-2.0)"
.toSpdx()
) shouldBe "BSD-3-Clause AND GPL-2.0-only WITH GCC-exception-2.0".toSpdx()

associateLicensesWithExceptions(
"GPL-2.0-only AND GPL-3.0-only AND Bootloader-exception AND Classpath-exception-2.0".toSpdx()
) shouldBe (
"GPL-2.0-only WITH Bootloader-exception AND " +
"GPL-3.0-only WITH Bootloader-exception AND " +
"GPL-2.0-only WITH Classpath-exception-2.0 AND " +
"GPL-3.0-only WITH Classpath-exception-2.0"
).toSpdx()
assertSoftly {
associateLicensesWithExceptions(
"MIT OR (GPL-2.0-only AND CC-BY-3.0 AND GCC-exception-2.0)".toSpdx()
) shouldBe "MIT OR (GPL-2.0-only WITH GCC-exception-2.0 AND CC-BY-3.0)".toSpdx()

associateLicensesWithExceptions(
"MIT OR (0BSD AND CC-BY-3.0 AND GCC-exception-2.0)".toSpdx()
) shouldBe "MIT OR (0BSD AND CC-BY-3.0 AND NOASSERTION WITH GCC-exception-2.0)".toSpdx()

associateLicensesWithExceptions(
@Suppress("MaxLineLength")
"(BSD-3-Clause AND GPL-2.0-only WITH GCC-exception-2.0) AND (GPL-2.0-only AND GCC-exception-2.0)".toSpdx()
) shouldBe "BSD-3-Clause AND GPL-2.0-only WITH GCC-exception-2.0".toSpdx()

associateLicensesWithExceptions(
"GPL-2.0-only AND GPL-3.0-only AND Bootloader-exception AND Classpath-exception-2.0".toSpdx()
) shouldBe (
"GPL-2.0-only WITH Bootloader-exception AND " +
"GPL-3.0-only WITH Bootloader-exception AND " +
"GPL-2.0-only WITH Classpath-exception-2.0 AND " +
"GPL-3.0-only WITH Classpath-exception-2.0"
).toSpdx()
}
}
}
}
Expand Down

0 comments on commit 320bb7c

Please sign in to comment.