Skip to content

Instantly share code, notes, and snippets.

@bstopp
Created August 6, 2024 14:22
Show Gist options
  • Save bstopp/f1f9fcdeefee94d9f1f451fa374f9273 to your computer and use it in GitHub Desktop.
Save bstopp/f1f9fcdeefee94d9f1f451fa374f9273 to your computer and use it in GitHub Desktop.
import assert from 'node:assert';
import { Miniflare } from 'miniflare';
describe('put copy', () => {
let mf;
let env;
beforeEach(async () => {
mf = new Miniflare({
modules: true,
script: `
export default {
async fetch(request, env, ctx) {
return new Response("Hello Miniflare!");
}
}
`,
r2Buckets: { BUCKET: 'BUCKET' },
});
env = await mf.getBindings();
});
afterEach(async () => {
if (mf) await mf.dispose();
});
it ('should support R2ObjectBody ReadableStream for put', async () => {
const key = 'index.html';
await env.BUCKET.put(key, 'Original Content');
const current = await env.BUCKET.get(key);
const update = await env.BUCKET.put('other.html', current.body);
assert(update);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment