Skip to content

Commit 488ec8e

Browse files
committed
fix(cli-helper): Properly delete temporary directories in tests
Avoid the use of `createOrtTempFile()` in test but use Kotest's `tempfile` instead which automatically deletes the file after the test has finished. Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
1 parent 3e68aa0 commit 488ec8e

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

cli-helper/src/funTest/kotlin/commands/CreateAnalyzerResultFromPackageListCommandFunTest.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ package org.ossreviewtoolkit.helper.commands
2121

2222
import com.github.ajalt.clikt.testing.test
2323

24+
import io.kotest.core.TestConfiguration
2425
import io.kotest.core.spec.style.WordSpec
2526
import io.kotest.engine.spec.tempdir
27+
import io.kotest.engine.spec.tempfile
2628
import io.kotest.matchers.shouldBe
2729

2830
import java.io.File
@@ -39,7 +41,6 @@ import org.ossreviewtoolkit.model.readValue
3941
import org.ossreviewtoolkit.model.toYaml
4042
import org.ossreviewtoolkit.utils.common.extractResource
4143
import org.ossreviewtoolkit.utils.ort.Environment
42-
import org.ossreviewtoolkit.utils.ort.createOrtTempFile
4344
import org.ossreviewtoolkit.utils.test.readResourceValue
4445

4546
class CreateAnalyzerResultFromPackageListCommandFunTest : WordSpec({
@@ -77,8 +78,8 @@ private val PACKAGE_CURATION = PackageCuration(
7778
)
7879
)
7980

80-
private fun createOrtConfig(): File {
81-
val packageCurationsFile = createOrtTempFile(suffix = ".yml").apply {
81+
private fun TestConfiguration.createOrtConfig(): File {
82+
val packageCurationsFile = tempfile(prefix = "curations", suffix = ".yml").apply {
8283
writeText(listOf(PACKAGE_CURATION).toYaml())
8384
}
8485

@@ -94,7 +95,7 @@ private fun createOrtConfig(): File {
9495
)
9596
)
9697

97-
val ortConfigFile = createOrtTempFile(suffix = "config.yml").apply {
98+
val ortConfigFile = tempfile(prefix = "config", suffix = ".yml").apply {
9899
writeText(mapOf("ort" to config).toYaml())
99100
}
100101

0 commit comments

Comments
 (0)