Skip to content

Commit db9e95a

Browse files
committed
test(common-utils): Stash directories with actual files inside
Enhance the test to also cover files as a preparation for upcoming changes. Signed-off-by: Sebastian Schuberth <[email protected]>
1 parent f64a53c commit db9e95a

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

utils/common/src/funTest/kotlin/DirectoryStashFunTest.kt

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import io.kotest.core.spec.style.StringSpec
2424
import io.kotest.core.test.TestCase
2525
import io.kotest.engine.spec.tempdir
2626
import io.kotest.matchers.file.aDirectory
27+
import io.kotest.matchers.file.aFile
2728
import io.kotest.matchers.file.containNFiles
2829
import io.kotest.matchers.file.exist
2930
import io.kotest.matchers.should
@@ -35,30 +36,45 @@ import java.io.IOException
3536

3637
class DirectoryStashFunTest : StringSpec() {
3738
private lateinit var sandboxDir: File
39+
3840
private lateinit var a: File
3941
private lateinit var aSubdir: File
42+
private lateinit var aNestedFile: File
43+
4044
private lateinit var b: File
4145
private lateinit var bSubdir: File
46+
private lateinit var bNestedFile: File
4247

4348
override suspend fun beforeTest(testCase: TestCase) {
4449
sandboxDir = tempdir()
50+
4551
a = sandboxDir / "a"
4652
aSubdir = a / "a-subdir"
53+
aNestedFile = aSubdir / "a-file"
54+
4755
b = sandboxDir / "b"
4856
bSubdir = b / "b-subdir"
57+
bNestedFile = bSubdir / "b-file"
4958

5059
check(aSubdir.mkdirs())
60+
check(aNestedFile.createNewFile())
61+
5162
check(bSubdir.mkdirs())
63+
check(bNestedFile.createNewFile())
5264
}
5365

5466
private fun sandboxDirShouldBeInOriginalState() {
5567
sandboxDir should containNFiles(2)
56-
a should containNFiles(1)
57-
b should containNFiles(1)
68+
5869
a shouldBe aDirectory()
70+
a should containNFiles(1)
5971
aSubdir shouldBe aDirectory()
72+
aNestedFile shouldBe aFile()
73+
6074
b shouldBe aDirectory()
75+
b should containNFiles(1)
6176
bSubdir shouldBe aDirectory()
77+
bNestedFile shouldBe aFile()
6278
}
6379

6480
init {

0 commit comments

Comments
 (0)