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