Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Miniflare 3] Fix cache tests following #515's preserving URL change #523

Merged
merged 1 commit into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/tre/src/plugins/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export const SCRIPT_ENTRY = `async function handleEvent(event) {
redirect: event.request.redirect,
body: event.request.body,
});
request.headers.delete("${HEADER_ORIGINAL_URL}");

if (globalThis.${BINDING_SERVICE_USER} === undefined) {
return new Response("No entrypoint worker found", { status: 404 });
Expand Down
5 changes: 2 additions & 3 deletions packages/tre/test/plugins/cache/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,14 @@ test.serial("operations persist cached data", async (t) => {
t.teardown(() => t.context.setOptions({}));

const key = "http://localhost/cache-persist";
const storedKey = new URL("/cache-persist", t.context.url).toString();

// Check put respects persist
await t.context.mf.dispatchFetch(key, {
method: "PUT",
headers: { "Test-Response-Cache-Control": "max-age=3600" },
body: "body",
});
let stored = await storage.get(storedKey);
let stored = await storage.get(key);
t.deepEqual(stored?.value, utf8Encode("body"));

// Check match respects persist
Expand All @@ -392,7 +391,7 @@ test.serial("operations persist cached data", async (t) => {
// Check delete respects persist
res = await t.context.mf.dispatchFetch(key, { method: "DELETE" });
t.is(res.status, 204);
stored = await storage.get(storedKey);
stored = await storage.get(key);
t.is(stored, undefined);
});
test.serial("operations are no-ops when caching disabled", async (t) => {
Expand Down