@@ -18,6 +18,17 @@ class FileHelperTest extends FlatSpec with Matchers {
18
18
result2 should be(" filename.ext" )
19
19
}
20
20
21
+ " FileHelper" should " stripPath with no common prefix" in {
22
+ val pathString : String = " filename.ext"
23
+ val pathString2 : String = " c/d/filename.ext"
24
+
25
+ val result : String = FileHelper .stripPath(pathString, " /a/b/" )
26
+ result should be(pathString)
27
+
28
+ val result2 : String = FileHelper .stripPath(pathString2, " /a/b/" )
29
+ result2 should be(pathString2)
30
+ }
31
+
21
32
" FileHelper" should " stripPath from Path" in {
22
33
val path : java.nio.file.Path = java.nio.file.Paths .get(" a/b/c/filename.ext" )
23
34
val pathPrefix : java.nio.file.Path = java.nio.file.Paths .get(" a/b" )
@@ -31,4 +42,22 @@ class FileHelperTest extends FlatSpec with Matchers {
31
42
val result2 : String = FileHelper .stripPath(path2, pathPrefix2)
32
43
result2 should be(" filename.ext" )
33
44
}
45
+
46
+ " FileHelper" should " createTmpFile" in {
47
+ val fileTmp = FileHelper .createTmpFile(" foo" , " prefix" , " .ext" ).toString
48
+
49
+ java.nio.file.Paths .get(fileTmp).getFileName.toString should startWith (" prefix" )
50
+ fileTmp should endWith (" .ext" )
51
+ io.Source .fromFile(fileTmp).mkString should be(" foo" )
52
+ }
53
+
54
+ " FileHelper" should " createFile" in {
55
+ val pathString : String = " filename.ext"
56
+
57
+ val file = FileHelper .createFile(pathString, " foo" ).toString
58
+
59
+ io.Source .fromFile(file).mkString should be(" foo" )
60
+
61
+ new java.io.File (file).delete()
62
+ }
34
63
}
0 commit comments