MCPcopy Create free account
hub / github.com/cfworker/cfworker / assertCanReadWriteCache

Function assertCanReadWriteCache

packages/dev/test/run-command.spec.js:160–182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

158}
159
160export async function assertCanReadWriteCache() {
161 const entry = './test/fixtures/worker.js';
162 const code = `
163 addEventListener('fetch', async e => {
164 await caches.default.put('/', new Response(undefined, { status: 201, statusText: 'no content' }));
165 const response = await caches.default.match('/');
166 e.respondWith(response);
167 });`;
168 await fs.outputFile(entry, code);
169 const command = new RunCommand({
170 entry,
171 port,
172 inspect: false,
173 watch: false,
174 check: false,
175 kv: []
176 });
177 await command.execute();
178 const response = await fetch('http://localhost:7000');
179 assert.equal(response.status, 201);
180 assert.equal(response.statusText, 'no content');
181 command.dispose();
182}
183
184export async function assertCanServeStaticSite() {
185 const entry = './test/fixtures/worker.js';

Callers

nothing calls this directly

Calls 2

executeMethod · 0.95
disposeMethod · 0.95

Tested by

no test coverage detected