2020-01-02 15:13:47 -05:00
|
|
|
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
|
2020-06-25 06:40:51 -04:00
|
|
|
import { assert } from "../testing/asserts.ts";
|
2019-10-16 14:39:33 -04:00
|
|
|
import * as path from "../path/mod.ts";
|
2020-06-25 06:40:51 -04:00
|
|
|
import { tempFile } from "./util.ts";
|
2019-02-10 18:49:48 -05:00
|
|
|
|
2020-06-12 15:23:38 -04:00
|
|
|
Deno.test({
|
2020-03-18 19:25:55 -04:00
|
|
|
name: "[io/util] tempfile",
|
2020-03-28 13:03:49 -04:00
|
|
|
fn: async function (): Promise<void> {
|
2020-03-18 19:25:55 -04:00
|
|
|
const f = await tempFile(".", {
|
|
|
|
prefix: "prefix-",
|
2020-03-28 13:03:49 -04:00
|
|
|
postfix: "-postfix",
|
2020-03-18 19:25:55 -04:00
|
|
|
});
|
|
|
|
const base = path.basename(f.filepath);
|
|
|
|
assert(!!base.match(/^prefix-.+?-postfix$/));
|
|
|
|
f.file.close();
|
2020-06-12 15:23:38 -04:00
|
|
|
await Deno.remove(f.filepath);
|
2020-03-28 13:03:49 -04:00
|
|
|
},
|
2019-02-10 18:49:48 -05:00
|
|
|
});
|