-
-
Notifications
You must be signed in to change notification settings - Fork 882
feat(tracing): enable tracing channels for unstorage #4226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,38 @@ | ||||||||||||||||
| import { describe, expect, it } from "vitest"; | ||||||||||||||||
| import type { Nitro } from "nitro/types"; | ||||||||||||||||
|
|
||||||||||||||||
| import storage from "../../src/build/virtual/storage.ts"; | ||||||||||||||||
|
|
||||||||||||||||
| function createNitroStub(tracingChannel: Nitro["options"]["tracingChannel"]): Nitro { | ||||||||||||||||
| return { | ||||||||||||||||
| options: { | ||||||||||||||||
| dev: true, | ||||||||||||||||
| preset: "nitro-dev", | ||||||||||||||||
| storage: {}, | ||||||||||||||||
| devStorage: {}, | ||||||||||||||||
| tracingChannel, | ||||||||||||||||
| }, | ||||||||||||||||
| } as unknown as Nitro; | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| describe("virtual/storage template", () => { | ||||||||||||||||
| it("does not wrap storage when tracingChannel is disabled", () => { | ||||||||||||||||
| const template = storage(createNitroStub(undefined)).template(); | ||||||||||||||||
| expect(template).not.toContain("withTracing"); | ||||||||||||||||
| expect(template).not.toContain("unstorage/tracing"); | ||||||||||||||||
| expect(template).toContain("return storage"); | ||||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
| it("does not wrap storage when tracingChannel.unstorage is false", () => { | ||||||||||||||||
| const template = storage( | ||||||||||||||||
| createNitroStub({ srvx: true, h3: true, unstorage: false }) | ||||||||||||||||
| ).template(); | ||||||||||||||||
| expect(template).not.toContain("withTracing"); | ||||||||||||||||
| }); | ||||||||||||||||
|
|
||||||||||||||||
|
||||||||||||||||
| it("wraps storage with withTracing when tracingChannel.unstorage is omitted", () => { | |
| const template = storage(createNitroStub({ srvx: true, h3: true })).template(); | |
| expect(template).toContain(`import { withTracing } from 'unstorage/tracing'`); | |
| expect(template).toContain("return withTracing(storage)"); | |
| }); |
Uh oh!
There was an error while loading. Please reload this page.