Devflare Docs
Testing Bindings

Test R2 the way Devflare expects it to run

R2 is Cloudflare object storage for files, uploads, generated assets, and private objects.

R2 is local-friendly, which means you can test real object operations without inventing a storage adapter just to get off the ground.

Use the runtime-shaped harness for direct bucket tests, then move up to worker-level tests when headers, auth, or file routing matter.

Best for
Object reads, writes, deletes, and route-level file-serving checks
Default harness
with or
Escalate when
You need to verify public delivery contracts or preview resource lifecycle

Start with the default test loop

R2 tests can be extremely small: put one object, read it back, and confirm the content or headers through the same worker path users will actually hit.

That is often enough to prove the binding, while the route test proves your app-level delivery rules.

Testing a real R2 binding

The helper surface to remember

  • Use when you are verifying the bucket contract itself.
  • Use when the route, auth, or response metadata is the thing that matters.
  • Keep at least one test close to the bucket API so the storage shape stays visible.

When to move beyond the default harness

  • A passing local bucket test does not mean your public asset topology is good; that still belongs to route and deployment design.
  • If the browser-facing path matters, assert the worker response instead of treating a bucket read as the whole user story.
  • Bucket provisioning and cleanup belong in preview or deploy-oriented checks when branch infrastructure matters.

Test the right layer

An object round-trip proves the binding. It does not automatically prove your file-delivery architecture.

Previous

R2 internals

R2 is simpler than KV or D1 because the authored value is already the bucket name, so there is no name-versus-id resolution dance.

Next

R2 example

This example uses one private bucket and one route, which is still the cleanest default shape for many real apps.