-
Notifications
You must be signed in to change notification settings - Fork 16
/
disk_cache_test.ts
45 lines (42 loc) · 1.34 KB
/
disk_cache_test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Copyright 2018-2024 the Deno authors. MIT license.
import { assertEquals, assertRejects } from "@std/assert";
import { DiskCache } from "./disk_cache.ts";
Deno.test({
name: "DiskCache.getCacheFilename()",
async fn() {
const testCases: [string, string | Error][] = [
[
"http://deno.land/std/http/file_server.ts",
"http/deno.land/d8300752800fe3f0beda9505dc1c3b5388beb1ee45afd1f1e2c9fc0866df15cf",
],
[
"http://localhost:8000/std/http/file_server.ts",
"http/localhost_PORT8000/d8300752800fe3f0beda9505dc1c3b5388beb1ee45afd1f1e2c9fc0866df15cf",
],
[
"https://deno.land/std/http/file_server.ts",
"https/deno.land/d8300752800fe3f0beda9505dc1c3b5388beb1ee45afd1f1e2c9fc0866df15cf",
],
["wasm://wasm/d1c677ea", new Error(`Can't convert url`)],
[
"file://127.0.0.1/d$/a/1/s/format.ts",
new Error(`Can't convert url`),
],
];
for (const [fixture, expected] of testCases) {
if (expected instanceof Error) {
await assertRejects(
async () => await DiskCache.getCacheFilename(new URL(fixture)),
Error,
expected.message,
);
continue;
} else {
assertEquals(
await DiskCache.getCacheFilename(new URL(fixture)),
expected,
);
}
}
},
});