Skip to content

Commit

Permalink
test(model): Add name(space) specific purl tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Oct 25, 2024
1 parent c535f61 commit a265d38
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions model/src/test/kotlin/utils/PurlUtilsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,21 @@ package org.ossreviewtoolkit.model.utils
import io.kotest.assertions.assertSoftly
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNot
import io.kotest.matchers.string.beEmpty
import io.kotest.matchers.string.shouldNotContain
import io.kotest.matchers.string.shouldNotContainIgnoringCase

import java.io.File

import org.ossreviewtoolkit.model.readValue

class PurlUtilsTest : StringSpec({
"The purl test suite should pass" {
val testDataFile = File("src/test/assets/test-suite-data.json")
val testData = testDataFile.readValue<List<TestSuiteData>>()
val testCases = testData.filterNot { it.isInvalid }
val testDataFile = File("src/test/assets/test-suite-data.json")
val testData = testDataFile.readValue<List<TestSuiteData>>()
val testCases = testData.filterNot { it.isInvalid }

"The purl test suite should pass" {
assertSoftly {
testCases.forEach { testCase ->
val purl = createPurl(
Expand All @@ -48,6 +52,23 @@ class PurlUtilsTest : StringSpec({
}
}
}

"The purl test cases should never have an empty namespace" {
assertSoftly {
testCases.filter { it.namespace != null }.forEach { testCase ->
testCase.namespace shouldNot beEmpty()
}
}
}

"The purl test cases should never contain slashes in names" {
assertSoftly {
testCases.forEach { testCase ->
testCase.name shouldNotContain "/"
testCase.name shouldNotContainIgnoringCase "%2F" // Encoded "/".
}
}
}
})

private data class TestSuiteData(
Expand Down

0 comments on commit a265d38

Please sign in to comment.