From 95597fc6e2ed9975c26eae77ba68ae42ca2c331a Mon Sep 17 00:00:00 2001 From: zfx <502545703@qq.com> Date: Fri, 31 Jul 2020 00:01:31 +0800 Subject: fix(std/tar): directory type bug (#6905) --- std/archive/tar_test.ts | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'std/archive/tar_test.ts') diff --git a/std/archive/tar_test.ts b/std/archive/tar_test.ts index 17dfe7745..0f7f51e30 100644 --- a/std/archive/tar_test.ts +++ b/std/archive/tar_test.ts @@ -395,3 +395,32 @@ Deno.test("untarLinuxGeneratedTar", async function (): Promise { file.close(); }); + +Deno.test("directoryEntryType", async function (): Promise { + const tar = new Tar(); + + tar.append("directory/", { + reader: new Deno.Buffer(), + contentSize: 0, + type: "directory", + }); + + const filePath = resolve("archive", "testdata"); + tar.append("archive/testdata/", { + filePath, + }); + + const outputFile = resolve("archive", "testdata", "directory_type_test.tar"); + const file = await Deno.open(outputFile, { create: true, write: true }); + await Deno.copy(tar.getReader(), file); + await file.close(); + + const reader = await Deno.open(outputFile, { read: true }); + const untar = new Untar(reader); + for await (const entry of untar) { + assertEquals(entry.type, "directory"); + } + + await reader.close(); + await Deno.remove(outputFile); +}); -- cgit v1.2.3