diff --git a/helper-cli/src/funTest/assets/create-analyzer-result-from-pkg-list-expected-output.yml b/helper-cli/src/funTest/assets/create-analyzer-result-from-pkg-list-expected-output.yml index c80b3d66ec479..01d6c55248ff2 100644 --- a/helper-cli/src/funTest/assets/create-analyzer-result-from-pkg-list-expected-output.yml +++ b/helper-cli/src/funTest/assets/create-analyzer-result-from-pkg-list-expected-output.yml @@ -110,4 +110,13 @@ analyzer: scanner: null advisor: null evaluator: null -resolved_configuration: {} +resolved_configuration: + package_curations: + - provider: + id: "File" + curations: + - id: "NPM::example-dependency-one:1.0.0" + curations: + comment: "Example curation." + vcs: + revision: "v1.0.0" diff --git a/helper-cli/src/funTest/kotlin/commands/CreateAnalyzerResultFromPackageListCommandFunTest.kt b/helper-cli/src/funTest/kotlin/commands/CreateAnalyzerResultFromPackageListCommandFunTest.kt index 079515fb815b6..3f7b441b2ad90 100644 --- a/helper-cli/src/funTest/kotlin/commands/CreateAnalyzerResultFromPackageListCommandFunTest.kt +++ b/helper-cli/src/funTest/kotlin/commands/CreateAnalyzerResultFromPackageListCommandFunTest.kt @@ -25,11 +25,20 @@ import io.kotest.core.spec.style.WordSpec import io.kotest.engine.spec.tempdir import io.kotest.matchers.shouldBe +import java.io.File + import org.ossreviewtoolkit.helper.HelperMain +import org.ossreviewtoolkit.model.Identifier import org.ossreviewtoolkit.model.OrtResult -import org.ossreviewtoolkit.model.ResolvedConfiguration +import org.ossreviewtoolkit.model.PackageCuration +import org.ossreviewtoolkit.model.PackageCurationData +import org.ossreviewtoolkit.model.VcsInfoCurationData +import org.ossreviewtoolkit.model.config.OrtConfiguration +import org.ossreviewtoolkit.model.config.ProviderPluginConfiguration import org.ossreviewtoolkit.model.readValue +import org.ossreviewtoolkit.model.toYaml import org.ossreviewtoolkit.utils.ort.Environment +import org.ossreviewtoolkit.utils.ort.createOrtTempFile import org.ossreviewtoolkit.utils.test.getAssetFile class CreateAnalyzerResultFromPackageListCommandFunTest : WordSpec({ @@ -38,9 +47,12 @@ class CreateAnalyzerResultFromPackageListCommandFunTest : WordSpec({ val inputFile = getAssetFile("package-list.yml") val outputFile = tempdir().resolve("analyzer-result.yml") val expectedOutputFile = getAssetFile("create-analyzer-result-from-pkg-list-expected-output.yml") + val ortConfigFile = createOrtConfig() HelperMain().test( "create-analyzer-result-from-package-list", + "--config", + ortConfigFile.absolutePath, "--package-list-file", inputFile.absolutePath, "--ort-file", @@ -53,8 +65,38 @@ class CreateAnalyzerResultFromPackageListCommandFunTest : WordSpec({ } }) -private fun OrtResult.patchAnalyzerResult(): OrtResult = - copy( - analyzer = analyzer?.copy(environment = Environment()), - resolvedConfiguration = ResolvedConfiguration() +private val PACKAGE_CURATION = PackageCuration( + id = Identifier("NPM::example-dependency-one:1.0.0"), + data = PackageCurationData( + comment = "Example curation.", + vcs = VcsInfoCurationData( + revision = "v1.0.0" + ) + ) +) + +private fun createOrtConfig(): File { + val packageCurationsFile = createOrtTempFile(suffix = ".yml").apply { + writeText(listOf(PACKAGE_CURATION).toYaml()) + } + + val config = OrtConfiguration().copy( + packageCurationProviders = listOf( + ProviderPluginConfiguration( + type = "File", + options = mapOf( + "path" to packageCurationsFile.absolutePath, + "mustExist" to "true" + ) + ) + ) ) + + val ortConfigFile = createOrtTempFile(suffix = "config.yml").apply { + writeText(mapOf("ort" to config).toYaml()) + } + + return ortConfigFile +} + +private fun OrtResult.patchAnalyzerResult(): OrtResult = copy(analyzer = analyzer?.copy(environment = Environment()))