feat(media): wire instrumentation — media repo spans + getMedia/listMedia/deleteMedia withSpan
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -32,7 +32,10 @@ function buildPayloadStub() {
|
||||
findByID: vi.fn(
|
||||
async ({ id }: { collection: string; id: string; overrideAccess?: boolean }) => {
|
||||
const doc = store.get(String(id));
|
||||
if (!doc) throw new Error(`Not found: ${id}`);
|
||||
if (!doc) {
|
||||
const err = Object.assign(new Error(`Not found: ${id}`), { status: 404 });
|
||||
throw err;
|
||||
}
|
||||
return doc;
|
||||
},
|
||||
),
|
||||
@@ -71,7 +74,9 @@ describe("MediaRepository", () => {
|
||||
it("returns undefined when Payload throws (not found)", async () => {
|
||||
const { getPayload } = await import("payload");
|
||||
(getPayload as ReturnType<typeof vi.fn>).mockResolvedValue({
|
||||
findByID: vi.fn().mockRejectedValue(new Error("Not found")),
|
||||
findByID: vi.fn().mockRejectedValue(
|
||||
Object.assign(new Error("Not found"), { status: 404 }),
|
||||
),
|
||||
});
|
||||
|
||||
const repo = new MediaRepository(stubPayloadConfig);
|
||||
|
||||
Reference in New Issue
Block a user