forked from lucacasonato/deno_httpcache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathredis_test.ts
33 lines (28 loc) · 1009 Bytes
/
redis_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
import { redisCache } from "./redis.ts";
import { assert, assertEquals } from "./test_deps.ts";
Deno.test("[redis] cache, retrieve, delete", async () => {
const cache = await redisCache("redis://127.0.0.1:6379", "cache-");
try {
const originalResp = new Response("Hello World", {
status: 200,
headers: {
"server": "deno",
"cache-control": "public, max-age=604800, immutable",
},
});
await cache.put("https://deno.land", originalResp);
const cachedResp = await cache.match("https://deno.land");
assert(cachedResp);
assertEquals(originalResp.status, cachedResp.status);
assertEquals(
originalResp.headers.get("server"),
cachedResp.headers.get("server"),
);
assertEquals(await originalResp.text(), await cachedResp.text());
await cache.delete("https://deno.land");
const otherCachedResp = await cache.match("https://deno.land");
assert(otherCachedResp === undefined);
} finally {
cache.close();
}
});