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