From b0a1ac8394a7c5089a9ab382c0641c6db085ea00 Mon Sep 17 00:00:00 2001 From: hasundue Date: Mon, 29 Jul 2024 14:07:06 +0900 Subject: [PATCH] chore: abandon `test` directory under the root --- test/fixtures/deno.jsonc | 26 ------- test/fixtures/deno.lock | 44 ----------- test/fixtures/deps.ts | 29 ------- test/fixtures/import_map/deno.json | 3 - test/fixtures/import_map/import_map.json | 5 -- test/fixtures/import_map/mod.ts | 1 - test/fixtures/lockfile/deno.json | 7 -- test/fixtures/lockfile/deno.lock | 37 --------- test/fixtures/lockfile/deno.updated.lock | 37 --------- test/fixtures/lockfile/mod.ts | 3 - test/fixtures/mod.ts | 2 - test/fixtures/mod_test.ts | 14 ---- test/mock.ts | 96 ------------------------ 13 files changed, 304 deletions(-) delete mode 100644 test/fixtures/deno.jsonc delete mode 100644 test/fixtures/deno.lock delete mode 100644 test/fixtures/deps.ts delete mode 100644 test/fixtures/import_map/deno.json delete mode 100644 test/fixtures/import_map/import_map.json delete mode 100644 test/fixtures/import_map/mod.ts delete mode 100644 test/fixtures/lockfile/deno.json delete mode 100644 test/fixtures/lockfile/deno.lock delete mode 100644 test/fixtures/lockfile/deno.updated.lock delete mode 100644 test/fixtures/lockfile/mod.ts delete mode 100644 test/fixtures/mod.ts delete mode 100644 test/fixtures/mod_test.ts delete mode 100644 test/mock.ts diff --git a/test/fixtures/deno.jsonc b/test/fixtures/deno.jsonc deleted file mode 100644 index 55a1507a..00000000 --- a/test/fixtures/deno.jsonc +++ /dev/null @@ -1,26 +0,0 @@ -{ - "imports": { - // NPM - "@octokit/core": "npm:@octokit/core@6.1.0", - // JSR - exact version - "@std/assert": "jsr:@std/assert@0.222.0", - // JSR - unversioned - "@std/bytes": "jsr:@std/bytes", - // JSR - variable - "@std/jsonc": "jsr:@std/jsoc@0.222.x", - // JSR - caret - "@std/testing": "jsr:@std/testing@^0.222.0", - // JSR - extended mapping - "@std/testing/bdd": "jsr:@std/testing@0.222.0/bdd", - // JSR - updated - "@std/yaml": "jsr:@std/yaml@123.456.789", - // Local - "lib/": "./lib/", - // HTTP - "x/deno_graph": "https://deno.land/x/deno_graph@0.50.0/mod.ts", - // HTTP - prefix - "std/": "https://deno.land/std@0.222.0/", - // HTTP - unversioned - "std/assert": "https://deno.land/std/assert/mod.ts" - } -} diff --git a/test/fixtures/deno.lock b/test/fixtures/deno.lock deleted file mode 100644 index 801e6519..00000000 --- a/test/fixtures/deno.lock +++ /dev/null @@ -1,44 +0,0 @@ -{ - "version": "3", - "packages": { - "specifiers": { - "jsr:@std/assert@0.222.0": "jsr:@std/assert@0.222.0", - "jsr:@std/fmt@^0.222.0": "jsr:@std/fmt@0.222.1", - "jsr:@std/testing@0.222.0": "jsr:@std/testing@0.222.0" - }, - "jsr": { - "@std/assert@0.222.0": { - "integrity": "cbf00c0d8125a56c087e3d1ea0e638760d47206b30e9d300bad826b811719fc7", - "dependencies": [ - "jsr:@std/fmt@^0.222.0" - ] - }, - "@std/fmt@0.222.1": { - "integrity": "ec3382f9b0261c1ab1a5c804aa355d816515fa984cdd827ed32edfb187c0a722" - }, - "@std/testing@0.222.0": { - "integrity": "a6d10c9fbb1df052ad7f73174d511328c08b7408bdd162ef6c3bc04def49c2ae" - } - } - }, - "remote": { - "https://deno.land/x/deno_graph@0.50.0/deno_graph_wasm.generated.js": "e1d58f79f4e33c7cc1062af565600f422a2fec1b5eaee42691f2a7992d9d5e6b", - "https://deno.land/x/deno_graph@0.50.0/loader.ts": "a2e757383908f4a51659fe1b1203386887ebb17756bac930a64856d613d8d57d", - "https://deno.land/x/deno_graph@0.50.0/media_type.ts": "a89a1b38d07c160e896de9ceb99285ba8391940140558304171066b5c3ef7609", - "https://deno.land/x/deno_graph@0.50.0/mod.ts": "47b5e8560f3e66468194742239fc76cf587d611dd43c1913eeebb9b1d94fc39f", - "https://deno.land/x/dir@1.5.1/data_local_dir/mod.ts": "91eb1c4bfadfbeda30171007bac6d85aadacd43224a5ed721bbe56bc64e9eb66", - "https://deno.land/x/wasmbuild@0.14.1/cache.ts": "89eea5f3ce6035a1164b3e655c95f21300498920575ade23161421f5b01967f4", - "https://deno.land/x/wasmbuild@0.14.1/loader.ts": "d98d195a715f823151cbc8baa3f32127337628379a02d9eb2a3c5902dbccfc02" - }, - "workspace": { - "dependencies": [ - "jsr:@std/assert@0.222.0", - "jsr:@std/bytes", - "jsr:@std/jsoc@0.222.x", - "jsr:@std/testing@0.222.0", - "jsr:@std/testing@^0.222.0", - "jsr:@std/yaml@123.456.789", - "npm:@octokit/core@6.1.0" - ] - } -} diff --git a/test/fixtures/deps.ts b/test/fixtures/deps.ts deleted file mode 100644 index 214ed0e1..00000000 --- a/test/fixtures/deps.ts +++ /dev/null @@ -1,29 +0,0 @@ -// NPM -import "npm:@octokit/core@6.1.0"; - -// JSR - exact version -import "jsr:@std/assert@0.222.0"; - -// JSR - unversioned -import "jsr:@std/bytes"; - -// JSR - variable -import "jsr:@std/jsonc@0.222.x"; - -// JSR - caret -import "jsr:@std/testing@^0.222.0"; - -// JSR - specific -import "jsr:@std/testing@0.222.0/bdd"; - -// JSR - updated -import "jsr:@std/yaml@123.456.789"; - -// HTTP -import "https://deno.land/x/deno_graph@0.50.0/mod.ts"; - -// HTTP - prefix -import "https://deno.land/std@0.222.0/"; - -// HTTP - unversioned -import "https://deno.land/std/assert/mod.ts"; diff --git a/test/fixtures/import_map/deno.json b/test/fixtures/import_map/deno.json deleted file mode 100644 index ee44ba94..00000000 --- a/test/fixtures/import_map/deno.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "importMap": "import_map.json" -} diff --git a/test/fixtures/import_map/import_map.json b/test/fixtures/import_map/import_map.json deleted file mode 100644 index 710d0582..00000000 --- a/test/fixtures/import_map/import_map.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "imports": { - "dax": "https://deno.land/x/dax@0.17.0/mod.ts" - } -} diff --git a/test/fixtures/import_map/mod.ts b/test/fixtures/import_map/mod.ts deleted file mode 100644 index 96f978e1..00000000 --- a/test/fixtures/import_map/mod.ts +++ /dev/null @@ -1 +0,0 @@ -import $ from "dax"; diff --git a/test/fixtures/lockfile/deno.json b/test/fixtures/lockfile/deno.json deleted file mode 100644 index 5a1ccddc..00000000 --- a/test/fixtures/lockfile/deno.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "imports": { - "std/bytes": "https://deno.land/std@0.200.0/bytes/copy.ts", - "hono": "npm:hono@^3", - "@core/match": "jsr:@core/match@0.1.x" - } -} diff --git a/test/fixtures/lockfile/deno.lock b/test/fixtures/lockfile/deno.lock deleted file mode 100644 index 10ff32c4..00000000 --- a/test/fixtures/lockfile/deno.lock +++ /dev/null @@ -1,37 +0,0 @@ -{ - "version": "3", - "packages": { - "specifiers": { - "jsr:@core/match@0.1.x": "jsr:@core/match@0.1.0", - "npm:hono@^3": "npm:hono@3.0.0", - "npm:ts-toolbelt@9.6.0": "npm:ts-toolbelt@9.6.0" - }, - "jsr": { - "@core/match@0.1.0": { - "integrity": "6f1edfca5215735a12aa2dbd920ead331a501eb5e3ad70cba3b9787610c7bfaf", - "dependencies": [ - "npm:ts-toolbelt@9.6.0" - ] - } - }, - "npm": { - "hono@3.0.0": { - "integrity": "sha512-OBWEvcRydCOLdOiazqOmKy8PXciR8uIyUM9HpmXot7UmwNBGOdEJvTrVRIgjV603w+go6cTXBOvFiQClSABT6Q==", - "dependencies": {} - }, - "ts-toolbelt@9.6.0": { - "integrity": "sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==", - "dependencies": {} - } - } - }, - "remote": { - "https://deno.land/std@0.200.0/bytes/copy.ts": "939d89e302a9761dcf1d9c937c7711174ed74c59eef40a1e4569a05c9de88219" - }, - "workspace": { - "dependencies": [ - "jsr:@core/match@0.1.x", - "npm:hono@^3" - ] - } -} diff --git a/test/fixtures/lockfile/deno.updated.lock b/test/fixtures/lockfile/deno.updated.lock deleted file mode 100644 index 20b4d003..00000000 --- a/test/fixtures/lockfile/deno.updated.lock +++ /dev/null @@ -1,37 +0,0 @@ -{ - "version": "3", - "packages": { - "specifiers": { - "jsr:@core/match@0.1.x": "jsr:@core/match@0.1.9", - "npm:hono@^3": "npm:hono@3.12.12", - "npm:ts-toolbelt@9.6.0": "npm:ts-toolbelt@9.6.0" - }, - "jsr": { - "@core/match@0.1.9": { - "integrity": "ceff06cf40212bb720925972a4405bef373efe768690b344ac4fd7ca7189f746", - "dependencies": [ - "npm:ts-toolbelt@9.6.0" - ] - } - }, - "npm": { - "hono@3.12.12": { - "integrity": "sha512-5IAMJOXfpA5nT+K0MNjClchzz0IhBHs2Szl7WFAhrFOsbtQsYmNynFyJRg/a3IPsmCfxcrf8txUGiNShXpK5Rg==", - "dependencies": {} - }, - "ts-toolbelt@9.6.0": { - "integrity": "sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==", - "dependencies": {} - } - } - }, - "remote": { - "https://deno.land/std@0.218.0/bytes/copy.ts": "f29c03168853720dfe82eaa57793d0b9e3543ebfe5306684182f0f1e3bfd422a" - }, - "workspace": { - "dependencies": [ - "jsr:@core/match@0.1.x", - "npm:hono@^3" - ] - } -} diff --git a/test/fixtures/lockfile/mod.ts b/test/fixtures/lockfile/mod.ts deleted file mode 100644 index 1ae6fa40..00000000 --- a/test/fixtures/lockfile/mod.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { copy } from "std/bytes"; -import { App } from "hono"; -import { match } from "@core/match"; diff --git a/test/fixtures/mod.ts b/test/fixtures/mod.ts deleted file mode 100644 index f5d16df0..00000000 --- a/test/fixtures/mod.ts +++ /dev/null @@ -1,2 +0,0 @@ -// http - export -export { createGraph } from "https://deno.land/x/deno_graph@0.50.0/mod.ts"; diff --git a/test/fixtures/mod_test.ts b/test/fixtures/mod_test.ts deleted file mode 100644 index cb363827..00000000 --- a/test/fixtures/mod_test.ts +++ /dev/null @@ -1,14 +0,0 @@ -// jsr - exact version -import { assertEquals } from "jsr:@std/assert@0.222.0"; - -// jsr - specific, mapped -import { describe, it } from "@std/testing/bdd"; - -// local -import { createGraph } from "./mod.ts"; - -describe("createGraph", () => { - it("should be a function", () => { - assertEquals(typeof createGraph, "function"); - }); -}); diff --git a/test/mock.ts b/test/mock.ts deleted file mode 100644 index 7768c024..00000000 --- a/test/mock.ts +++ /dev/null @@ -1,96 +0,0 @@ -import { stub } from "@std/testing/mock"; - -export const FetchStub = { - create( - createResponse: ( - request: string | URL | Request, - init: RequestInit & { original: typeof fetch }, - ) => Response | Promise, - ) { - const original = globalThis.fetch; - return stub( - globalThis, - "fetch", - (request, init) => - Promise.resolve(createResponse(request, { ...init, original })), - ); - }, -}; -export type FetchStub = ReturnType; - -export const LatestVersionStub = { - create( - replacer: string | Record, - ): FetchStub { - return FetchStub.create((request, init) => { - request = (request instanceof Request) - ? request - : new Request(request, init); - const url = new URL(request.url); - const latest = typeof replacer === "string" - ? replacer - : Object.entries(replacer) - .find(([pattern]) => url.href.includes(pattern))?.[1] ?? - replacer["_"]; - if (!latest) { - return init.original(request, init); - } - switch (url.hostname) { - case "registry.npmjs.org": - return new Response( - JSON.stringify({ "dist-tags": { latest } }), - { status: 200 }, - ); - case "jsr.io": - if (!url.pathname.endsWith("meta.json")) { - return init.original(request, init); - } - return new Response( - JSON.stringify({ - versions: { - [latest]: {}, - }, - }), - { status: 200 }, - ); - case "deno.land": { - if (request.method !== "HEAD") { - return init.original(request); - } - const { name, path } = parseDenoLandUrl(url); - return { - arrayBuffer: () => Promise.resolve(new ArrayBuffer(0)), - redirected: true, - status: 302, - url: `https://${name}@${latest}${path}`, - } as Response; - } - default: - return init.original(request, init); - } - }); - }, -}; -export type LatestVersionStub = ReturnType; - -function parseDenoLandUrl(url: URL) { - const std = url.pathname.startsWith("/std"); - const matched = std - ? url.pathname.match( - /^\/std(?:@(?[^/]+))?(?\/(.*)$)/, - ) - : url.pathname.match( - /^\/x\/(?[^/]+)(?:@(?[^/]+))?(?\/(.*)$)/, - ); - if (!matched) { - throw new Error(`Unexpected URL: ${url}`); - } - const { name, version, path } = matched.groups!; - return { - name: std ? "deno.land/std" : `deno.land/x/${name}`, - version, - // Remove a trailing slash if it exists to imitate the behavior of typical - // Web servers. - path: path.replace(/\/$/, ""), - }; -}