cloudflare / cloudflare/cloudflare-docs
Document `adminSecretsStore()` in `cloudflare:test` for vitest-pool-workers
- Dominant language
- MDX
- Stars
- 5.2k
- Forks
- 16.7k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 337
Description
## Summary
`@cloudflare/vitest-pool-workers` is adding a new `adminSecretsStore()` export to `cloudflare:test` (cloudflare/workers-sdk#13073). This gives tests write access to secrets store bindings, which are otherwise read-only (`.get()` only).
## Usage
```ts
import { adminSecretsStore } from "cloudflare:test";
import { env } from "cloudflare:workers";
const admin = adminSecretsStore(env.MY_SECRET);
await admin.create("test-value");
const value = await env.MY_SECRET.get(); // "test-value"
```
## Admin API methods
- `create(value: string): Promise` — create a secret, returns its ID
- `update(value: string, id: string): Promise` — update a secret by ID
- `duplicate(id: string, newName: string): Promise` — duplicate a secret under a new name
- `delete(id: string): Promise` — delete a secret by ID
- `list(): Promise<{ name: string; metadata?: { uuid: string } }[]>` — list all secrets
- `get(id: string): Promise` — get a secret's name by ID
## Where to document
This should be added to the [vitest-pool-workers testing documentation](https://developers.cloudflare.com/workers/testing/vitest-integration/), likely alongside the existing `applyD1Migrations()` documentation as another binding-seeding helper.
Contributor guide
Assessment
This issue has not been assessed yet.