-
Notifications
You must be signed in to change notification settings - Fork 186
/
basic.test.w
53 lines (37 loc) · 1.25 KB
/
basic.test.w
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
bring fs;
let tmpdir = fs.mkdtemp();
let filepath = "{tmpdir}/hello-preflight.txt";
let data = "Hello, Wing!";
let appendData = " Time to take flight!";
fs.writeFile(filepath, data);
assert(fs.exists(filepath) == true);
let content = fs.readFile(filepath);
assert(content == data);
fs.appendFile(filepath, appendData);
assert(fs.exists(filepath) == true);
let newContent = fs.readFile(filepath);
assert(newContent == data + appendData);
fs.remove(filepath);
assert(fs.exists(filepath) == false);
let nilContent = fs.tryReadFile(filepath);
assert(nilContent == nil);
fs.remove(tmpdir);
assert(fs.exists(tmpdir) == false);
test "inflight file basic operations" {
let tmpdir = fs.mkdtemp();
let filepath = "{tmpdir}/hello-inflight.txt";
fs.writeFile(filepath, data);
assert(fs.exists(filepath) == true);
let content = fs.readFile(filepath);
assert(content == data);
fs.appendFile(filepath, appendData);
assert(fs.exists(filepath) == true);
let newContent = fs.readFile(filepath);
assert(newContent == data + appendData);
fs.remove(filepath);
assert(fs.exists(filepath) == false);
let nilContent = fs.tryReadFile(filepath);
assert(nilContent == nil);
fs.remove(tmpdir);
assert(fs.exists(tmpdir) == false);
}