From 320bb7c100d873b7d985e15bfba546bf686f343a Mon Sep 17 00:00:00 2001 From: Sebastian Schuberth Date: Wed, 13 Dec 2023 13:35:56 +0100 Subject: [PATCH] test(model): Assert multiple assertions in a test case softly Do not throw already on the first assertion failure. Signed-off-by: Sebastian Schuberth --- .../test/kotlin/utils/FindingsMatcherTest.kt | 45 ++++++++++--------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/model/src/test/kotlin/utils/FindingsMatcherTest.kt b/model/src/test/kotlin/utils/FindingsMatcherTest.kt index 04cbe78ddf457..b7a118d195bd4 100644 --- a/model/src/test/kotlin/utils/FindingsMatcherTest.kt +++ b/model/src/test/kotlin/utils/FindingsMatcherTest.kt @@ -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 @@ -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() + } } } }