Skip to content

Commit

Permalink
test(common-utils): Add a test for deleting read-only files
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Sep 3, 2024
1 parent a4d249f commit bb012f3
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions utils/common/src/test/kotlin/ExtensionsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,23 @@ class ExtensionsTest : WordSpec({
}
}

"File.safeDeleteRecursively()" should {
"be able to delete files that are not writable" {
val dir = tempdir().apply {
resolve("read-only.txt").apply {
writeText("Hello!")
check(setWritable(false))
}
}

shouldNotThrow<IOException> {
dir.safeDeleteRecursively(force = true)
}

dir.exists() shouldBe false
}
}

"File.expandTilde()" should {
"expand the path if the SHELL environment variable is set".config(enabled = Os.env["SHELL"] != null) {
File("~/Desktop").expandTilde() shouldBe Os.userHomeDirectory.resolve("Desktop")
Expand Down

0 comments on commit bb012f3

Please sign in to comment.