@@ -4,6 +4,7 @@ import io.scalajs.nodejs.buffer.Buffer
4
4
import org .scalatest .{AsyncFunSpec , BeforeAndAfterEach }
5
5
6
6
import scala .concurrent .{ExecutionContext , Future }
7
+ import scala .util .{Failure , Success }
7
8
8
9
class FsAsyncTest extends AsyncFunSpec with BeforeAndAfterEach {
9
10
@@ -40,5 +41,49 @@ class FsAsyncTest extends AsyncFunSpec with BeforeAndAfterEach {
40
41
}
41
42
}
42
43
}
44
+
45
+ describe(" accessFuture" ) {
46
+ it(" should succeed" ) {
47
+ for {
48
+ _ <- Fs .accessFuture(" package.json" )
49
+ _ <- Fs .accessFuture(" package.json" , Fs .constants.R_OK )
50
+ } yield {
51
+ succeed
52
+ }
53
+ }
54
+
55
+ it(" should fail: no such file" ) {
56
+ Fs .accessFuture(" package.json111" ).transformWith {
57
+ case Failure (_) => succeed
58
+ case Success (_) => fail(" expected failure" )
59
+ }
60
+ }
61
+
62
+ it(" should fail: invalid file mode" ) {
63
+ Fs .accessFuture(" package.json" , Fs .constants.X_OK ).transformWith {
64
+ case Failure (_) => succeed
65
+ case Success (_) => fail(" expected failure" )
66
+ }
67
+ }
68
+ }
69
+
70
+ describe(" appendFileFuture" ) {
71
+ it(" should support option" ) {
72
+ for {
73
+ _ <- Fs .appendFileFuture(" x.AppendFile.txt" , " yay" )
74
+ _ <- Fs .appendFileFuture(" x.AppendFile.sh" , " echo 0" , new FileAppendOptions (mode = Fs .constants.X_OK ))
75
+ defaultStat <- Fs .statFuture(" x.AppendFile.txt" )
76
+ executableStat <- Fs .statFuture(" x.AppendFile.sh" )
77
+ _ <- Fs .unlinkFuture(" x.AppendFile.txt" )
78
+ _ <- Fs .unlinkFuture(" x.AppendFile.sh" )
79
+ } yield {
80
+ assert((defaultStat.mode & Fs .constants.R_OK ) > 0 )
81
+ assert((defaultStat.mode & Fs .constants.X_OK ) === 0 )
82
+ assert((executableStat.mode & Fs .constants.R_OK ) === 0 )
83
+ assert((executableStat.mode & Fs .constants.X_OK ) > 0 )
84
+ succeed
85
+ }
86
+ }
87
+ }
43
88
}
44
89
}
0 commit comments