Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further small Conan improvements #8912

Merged
merged 7 commits into from
Jul 19, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import org.ossreviewtoolkit.model.VcsType
import org.ossreviewtoolkit.model.config.FileArchiverConfiguration
import org.ossreviewtoolkit.utils.test.PostgresListener

private val SOURCE_ARTIFACT_PROVENANCE = ArtifactProvenance(sourceArtifact = RemoteArtifact("url", Hash.create("hash")))
private val SOURCE_ARTIFACT_PROVENANCE = ArtifactProvenance(RemoteArtifact("https://example.com/", Hash.NONE))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to add an alternative constructor which does not have these sanity checks, so that we can more easily choose values in tests?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was also a bit torn between the options. As the Hash class is also part of the serialized data / file model, IMO the data class itself indeed should not have such sanity checks. Instead, an interface that abstracts away the concrete data storage format should have these checks. As this is a reoccurring topic I've created this epic for it.

But for now, I believe it's a good change to add some sanity and not make data too fake.

private val VCS_PROVENANCE = RepositoryProvenance(
vcsInfo = VcsInfo(
type = VcsType.GIT,
Expand Down
3 changes: 1 addition & 2 deletions model/src/test/kotlin/licenses/LicenseInfoResolverTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import java.lang.IllegalArgumentException
import org.ossreviewtoolkit.model.ArtifactProvenance
import org.ossreviewtoolkit.model.CopyrightFinding
import org.ossreviewtoolkit.model.Hash
import org.ossreviewtoolkit.model.HashAlgorithm
import org.ossreviewtoolkit.model.Identifier
import org.ossreviewtoolkit.model.LicenseFinding
import org.ossreviewtoolkit.model.LicenseSource
Expand Down Expand Up @@ -338,7 +337,7 @@ class LicenseInfoResolverTest : WordSpec({
"apply path excludes" {
val sourceArtifact = RemoteArtifact(
url = "https://example.com/",
hash = Hash("", HashAlgorithm.NONE)
hash = Hash.NONE
)
val sourceArtifactProvenance = ArtifactProvenance(
sourceArtifact = sourceArtifact
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import org.ossreviewtoolkit.analyzer.create
import org.ossreviewtoolkit.analyzer.resolveSingleProject
import org.ossreviewtoolkit.model.AnalyzerResult
import org.ossreviewtoolkit.model.Hash
import org.ossreviewtoolkit.model.HashAlgorithm
import org.ossreviewtoolkit.model.toYaml
import org.ossreviewtoolkit.utils.test.getAssetFile
import org.ossreviewtoolkit.utils.test.matchExpectedResult
Expand Down Expand Up @@ -122,8 +121,8 @@ private fun AnalyzerResult.patchPackages(): AnalyzerResult {
pkg.takeUnless { it.id.toCoordinates().startsWith("Maven:com.android.tools.build:aapt2:") }
?: pkg.copy(
binaryArtifact = pkg.binaryArtifact.copy(
url = "***",
hash = Hash("***", HashAlgorithm.SHA1)
url = "https://example.com/",
hash = Hash.NONE
)
)
}
Expand Down
8 changes: 4 additions & 4 deletions reporter/src/testFixtures/kotlin/TestData.kt
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ val ORT_RESULT = OrtResult(
provenance = ArtifactProvenance(
sourceArtifact = RemoteArtifact(
url = "https://example.com/license-file-1.0.tgz",
hash = Hash(value = "", algorithm = HashAlgorithm.SHA1)
hash = Hash.NONE
)
),
scanner = ScannerDetails(name = "scanner", version = "1.0", configuration = ""),
Expand Down Expand Up @@ -305,7 +305,7 @@ val ORT_RESULT = OrtResult(
provenance = ArtifactProvenance(
sourceArtifact = RemoteArtifact(
url = "https://example.com/license-file-and-additional-licenses-1.0.tgz",
hash = Hash(value = "", algorithm = HashAlgorithm.SHA1)
hash = Hash.NONE
)
),
scanner = ScannerDetails(name = "scanner", version = "1.0", configuration = ""),
Expand Down Expand Up @@ -346,7 +346,7 @@ val ORT_RESULT = OrtResult(
provenance = ArtifactProvenance(
sourceArtifact = RemoteArtifact(
url = "https://example.com/concluded-license-1.0.tgz",
hash = Hash(value = "", algorithm = HashAlgorithm.SHA1)
hash = Hash.NONE
)
),
scanner = ScannerDetails(name = "scanner", version = "1.0", configuration = ""),
Expand Down Expand Up @@ -379,7 +379,7 @@ val ORT_RESULT = OrtResult(
provenance = ArtifactProvenance(
sourceArtifact = RemoteArtifact(
url = "https://example.com/declared-license-1.0.tgz",
hash = Hash(value = "", algorithm = HashAlgorithm.SHA1)
hash = Hash.NONE
)
),
scanner = ScannerDetails(name = "scanner", version = "1.0", configuration = ""),
Expand Down
2 changes: 1 addition & 1 deletion utils/test/src/main/kotlin/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fun scannerRunOf(vararg pkgScanResults: Pair<Identifier, List<ScanResult>>): Sca
provenance = ArtifactProvenance(
sourceArtifact = RemoteArtifact(
url = id.toPurl(),
hash = Hash(value = "", algorithm = HashAlgorithm.NONE)
hash = Hash.NONE
)
)
)
Expand Down