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

test(common-utils): Verify stashed directories to be restored on exception #9582

Merged
merged 1 commit into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions utils/common/src/funTest/kotlin/DirectoryStashFunTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.ossreviewtoolkit.utils.common

import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.spec.style.StringSpec
import io.kotest.core.test.TestCase
import io.kotest.engine.spec.tempdir
Expand All @@ -29,6 +30,7 @@ import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNot

import java.io.File
import java.io.IOException

class DirectoryStashFunTest : StringSpec() {
private lateinit var sandboxDir: File
Expand Down Expand Up @@ -134,5 +136,15 @@ class DirectoryStashFunTest : StringSpec() {

sandboxDirShouldBeInOriginalState()
}

"stashed directories are restored even if an exception is thrown" {
shouldThrow<IOException> {
stashDirectories(a, b).use {
throw IOException()
}
}

sandboxDirShouldBeInOriginalState()
}
}
}
Loading