summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2020-06-21 21:29:44 +0800
committerGitHub <noreply@github.com>2020-06-21 09:29:44 -0400
commit40866d7cd521a2f33ac60d841e1706c2f68ecc66 (patch)
treea0876c5dd3d63b814490a4a0ca6c511580e2170c /cli/tests
parentf24aab81c9c97fe933a9c6d9a02fbc70df60af37 (diff)
feat(unstable): add Deno.fsyncSync and fsync (#6411)
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/unit/sync_test.ts38
-rw-r--r--cli/tests/unit/unit_tests.ts1
2 files changed, 39 insertions, 0 deletions
diff --git a/cli/tests/unit/sync_test.ts b/cli/tests/unit/sync_test.ts
new file mode 100644
index 000000000..7a489e951
--- /dev/null
+++ b/cli/tests/unit/sync_test.ts
@@ -0,0 +1,38 @@
+// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
+import { unitTest, assertEquals } from "./test_util.ts";
+
+unitTest(
+ { perms: { read: true, write: true } },
+ function fsyncSyncSuccess(): void {
+ const filename = Deno.makeTempDirSync() + "/test_fsyncSync.txt";
+ const file = Deno.openSync(filename, {
+ read: true,
+ write: true,
+ create: true,
+ });
+ const size = 64;
+ Deno.ftruncateSync(file.rid, size);
+ Deno.fsyncSync(file.rid);
+ assertEquals(Deno.statSync(filename).size, size);
+ Deno.close(file.rid);
+ Deno.removeSync(filename);
+ }
+);
+
+unitTest(
+ { perms: { read: true, write: true } },
+ async function fsyncSuccess(): Promise<void> {
+ const filename = (await Deno.makeTempDir()) + "/test_fsync.txt";
+ const file = await Deno.open(filename, {
+ read: true,
+ write: true,
+ create: true,
+ });
+ const size = 64;
+ await Deno.ftruncate(file.rid, size);
+ await Deno.fsync(file.rid);
+ assertEquals((await Deno.stat(filename)).size, size);
+ Deno.close(file.rid);
+ await Deno.remove(filename);
+ }
+);
diff --git a/cli/tests/unit/unit_tests.ts b/cli/tests/unit/unit_tests.ts
index b16141bdc..1701170d1 100644
--- a/cli/tests/unit/unit_tests.ts
+++ b/cli/tests/unit/unit_tests.ts
@@ -59,6 +59,7 @@ import "./streams_piping_test.ts";
import "./streams_transform_test.ts";
import "./streams_writable_test.ts";
import "./symlink_test.ts";
+import "./sync_test.ts";
import "./text_encoding_test.ts";
import "./testing_test.ts";
import "./timers_test.ts";