summaryrefslogtreecommitdiff
path: root/std/node/_fs/_fs_copy_test.ts
blob: 45e7e937274faf75d2e9453c1f886f6e78a54ba7 (plain)
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
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { copyFile, copyFileSync } from "./_fs_copy.ts";
import { existsSync } from "./_fs_exists.ts";

import { assert } from "../../testing/asserts.ts";
const { test } = Deno;

const destFile = "./destination.txt";

test({
  name: "[std/node/fs] copy file",
  fn: async () => {
    const srouceFile = Deno.makeTempFileSync();
    const err = await new Promise((resolve) => {
      copyFile(srouceFile, destFile, (err: Error | undefined) => resolve(err));
    });
    assert(!err);
    assert(existsSync(destFile));
    Deno.removeSync(srouceFile);
    Deno.removeSync(destFile);
  },
});

test({
  name: "[std/node/fs] copy file sync",
  fn: () => {
    const srouceFile = Deno.makeTempFileSync();
    copyFileSync(srouceFile, destFile);
    assert(existsSync(destFile));
    Deno.removeSync(srouceFile);
    Deno.removeSync(destFile);
  },
});