|
19 | 19 |
|
20 | 20 | package org.ossreviewtoolkit.model
|
21 | 21 |
|
| 22 | +import io.kotest.assertions.throwables.shouldThrow |
22 | 23 | import io.kotest.core.spec.style.WordSpec
|
23 | 24 | import io.kotest.matchers.collections.containExactlyInAnyOrder
|
24 | 25 | import io.kotest.matchers.maps.containExactly
|
25 | 26 | import io.kotest.matchers.nulls.shouldNotBeNull
|
26 | 27 | import io.kotest.matchers.should
|
| 28 | +import io.kotest.matchers.string.shouldContain |
27 | 29 |
|
28 | 30 | import org.ossreviewtoolkit.model.FileList.Entry
|
29 | 31 | import org.ossreviewtoolkit.model.utils.alignRevisions
|
30 | 32 | import org.ossreviewtoolkit.model.utils.clearVcsPath
|
31 | 33 |
|
32 | 34 | class ScannerRunTest : WordSpec({
|
| 35 | + "init" should { |
| 36 | + "error on duplicate provenance scan results" { |
| 37 | + val provenance = RepositoryProvenance( |
| 38 | + VcsInfo(type = VcsType.GIT, url = "https://github.com/example.git", revision = "revision"), |
| 39 | + "revision" |
| 40 | + ) |
| 41 | + |
| 42 | + val ex = shouldThrow<IllegalArgumentException> { |
| 43 | + ScannerRun.EMPTY.copy( |
| 44 | + provenances = setOf( |
| 45 | + ProvenanceResolutionResult( |
| 46 | + id = Identifier("maven::example:1.0"), |
| 47 | + packageProvenance = provenance |
| 48 | + ) |
| 49 | + ), |
| 50 | + scanResults = setOf( |
| 51 | + ScanResult( |
| 52 | + provenance = provenance, |
| 53 | + scanner = ScannerDetails.EMPTY, |
| 54 | + summary = ScanSummary.EMPTY.copy( |
| 55 | + licenseFindings = setOf( |
| 56 | + LicenseFinding("MIT", TextLocation("file1.txt", 1, 1)) |
| 57 | + ) |
| 58 | + ) |
| 59 | + ), |
| 60 | + ScanResult( |
| 61 | + provenance = provenance, |
| 62 | + scanner = ScannerDetails.EMPTY, |
| 63 | + summary = ScanSummary.EMPTY.copy( |
| 64 | + licenseFindings = setOf( |
| 65 | + LicenseFinding("MIT", TextLocation("file2.txt", 1, 1)) |
| 66 | + ) |
| 67 | + ) |
| 68 | + ) |
| 69 | + ) |
| 70 | + ) |
| 71 | + } |
| 72 | + |
| 73 | + ex.message shouldContain "Found multiple scan results for the same provenance" |
| 74 | + } |
| 75 | + |
| 76 | + "error on duplicate provenance file lists" { |
| 77 | + val provenance = RepositoryProvenance( |
| 78 | + VcsInfo(type = VcsType.GIT, url = "https://github.com/example.git", revision = "revision"), |
| 79 | + "revision" |
| 80 | + ) |
| 81 | + |
| 82 | + val ex = shouldThrow<IllegalArgumentException> { |
| 83 | + ScannerRun.EMPTY.copy( |
| 84 | + provenances = setOf( |
| 85 | + ProvenanceResolutionResult( |
| 86 | + id = Identifier("maven::example:1.0"), |
| 87 | + packageProvenance = provenance |
| 88 | + ) |
| 89 | + ), |
| 90 | + files = setOf( |
| 91 | + FileList( |
| 92 | + provenance = provenance, |
| 93 | + files = setOf( |
| 94 | + Entry( |
| 95 | + path = "vcs/path/file1.txt", |
| 96 | + sha1 = "1111111111111111111111111111111111111111" |
| 97 | + ) |
| 98 | + ) |
| 99 | + ), |
| 100 | + FileList( |
| 101 | + provenance = provenance, |
| 102 | + files = setOf( |
| 103 | + Entry( |
| 104 | + path = "some/dir/file2.txt", |
| 105 | + sha1 = "2222222222222222222222222222222222222222" |
| 106 | + ) |
| 107 | + ) |
| 108 | + ) |
| 109 | + ) |
| 110 | + ) |
| 111 | + } |
| 112 | + |
| 113 | + ex.message shouldContain "Found multiple file lists for the same provenance" |
| 114 | + } |
| 115 | + } |
| 116 | + |
33 | 117 | "getFileList()" should {
|
34 | 118 | "filter by VCS path and merge sub-repository lists as expected" {
|
35 | 119 | val id = Identifier("a:b:c:1.0.0")
|
|
0 commit comments