summaryrefslogtreecommitdiff
path: root/std/mime/multipart_test.ts
diff options
context:
space:
mode:
authorCasper Beyer <caspervonb@pm.me>2020-09-09 17:24:47 +0800
committerGitHub <noreply@github.com>2020-09-09 11:24:47 +0200
commit79b25106170b1c35103aeea6cb8cf549e807e50c (patch)
tree5589521c1d3171ba3a9a39b027b69890f8a917b1 /std/mime/multipart_test.ts
parent11afd071aec2d5ea6eb37a934c0835d8f6b1e764 (diff)
test(std/mime): make tests runnable from any directory (#7398)
Diffstat (limited to 'std/mime/multipart_test.ts')
-rw-r--r--std/mime/multipart_test.ts12
1 files changed, 7 insertions, 5 deletions
diff --git a/std/mime/multipart_test.ts b/std/mime/multipart_test.ts
index d2cfb2ee5..df533194c 100644
--- a/std/mime/multipart_test.ts
+++ b/std/mime/multipart_test.ts
@@ -19,7 +19,9 @@ const e = new TextEncoder();
const boundary = "--abcde";
const dashBoundary = e.encode("--" + boundary);
const nlDashBoundary = e.encode("\r\n--" + boundary);
-const testdataDir = path.resolve("mime", "testdata");
+
+const moduleDir = path.dirname(path.fromFileUrl(import.meta.url));
+const testdataDir = path.resolve(moduleDir, "testdata");
Deno.test("multipartScanUntilBoundary1", function (): void {
const data = `--${boundary}`;
@@ -92,7 +94,7 @@ Deno.test("multipartMultipartWriter", async function (): Promise<void> {
const mw = new MultipartWriter(buf);
await mw.writeField("foo", "foo");
await mw.writeField("bar", "bar");
- const f = await Deno.open(path.resolve("./mime/testdata/sample.txt"), {
+ const f = await Deno.open(path.join(testdataDir, "sample.txt"), {
read: true,
});
await mw.writeFile("file", "sample.txt", f);
@@ -175,7 +177,7 @@ Deno.test("multipartMultipartWriter3", async function (): Promise<void> {
Deno.test({
name: "[mime/multipart] readForm() basic",
async fn() {
- const o = await Deno.open(path.resolve("./mime/testdata/sample.txt"));
+ const o = await Deno.open(path.join(testdataDir, "sample.txt"));
const mr = new MultipartReader(
o,
"--------------------------434049563556637648550474",
@@ -247,7 +249,7 @@ Deno.test({
Deno.test({
name: "[mime/multipart] removeAll() should remove all tempfiles",
async fn() {
- const o = await Deno.open(path.resolve("./mime/testdata/sample.txt"));
+ const o = await Deno.open(path.join(testdataDir, "sample.txt"));
const mr = new MultipartReader(
o,
"--------------------------434049563556637648550474",
@@ -274,7 +276,7 @@ Deno.test({
Deno.test({
name: "[mime/multipart] entries()",
async fn() {
- const o = await Deno.open(path.resolve("./mime/testdata/sample.txt"));
+ const o = await Deno.open(path.join(testdataDir, "sample.txt"));
const mr = new MultipartReader(
o,
"--------------------------434049563556637648550474",