Skip to content

Commit

Permalink
Add snapshot for create pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
cmackenzie1 committed Jan 15, 2025
1 parent ad9749a commit c70d322
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
22 changes: 22 additions & 0 deletions packages/wrangler/src/__tests__/pipelines.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { http, HttpResponse } from "msw";
import { describe, expect, it } from "vitest";
import { normalizeOutput } from "../../e2e/helpers/normalize";
import { __testSkipDelays } from "../pipelines";
import { endEventLoop } from "./helpers/end-event-loop";
Expand Down Expand Up @@ -320,6 +321,27 @@ describe("pipelines", () => {
"pipelines create my-pipeline --r2-bucket test-bucket --r2-access-key-id my-key --r2-secret-access-key my-secret"
);
expect(requests.count).toEqual(1);
expect(std.out).toMatchInlineSnapshot(`
"🌀 Creating pipeline named \\"my-pipeline\\"
✅ Successfully created pipeline \\"my-pipeline\\" with id 0001
🎉 You can now send data to your pipeline!
To start interacting with this Pipeline from a Worker, open your Worker’s config file and add the following binding configuration:
{
\\"pipelines\\": [
{
\\"pipeline\\": \\"my-pipeline\\",
\\"binding\\": \\"PIPELINE\\"
}
]
}
Send data to your pipelines HTTP endpoint:
curl \\"foo\\" -d '[{\\"foo\\": \\"bar\\"}]'
"
`);
});

it("should fail a missing bucket", async () => {
Expand Down
22 changes: 9 additions & 13 deletions packages/wrangler/src/pipelines/cli/create.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import dedent from "ts-dedent";
import { formatConfigSnippet, readConfig } from "../../config";
import { FatalError, UserError } from "../../errors";
import { logger } from "../../logger";
Expand Down Expand Up @@ -294,11 +293,11 @@ export async function createPipelineHandler(
);
logger.log("🎉 You can now send data to your pipeline!");
if (args.enableWorkerBinding) {
logger.log(dedent`
To start interacting with this Pipeline from a Worker, open your Worker’s config file and add the following binding configuration:
${formatConfigSnippet(
logger.log(
`\nTo start interacting with this Pipeline from a Worker, open your Worker’s config file and add the following binding configuration:\n`
);
logger.log(
formatConfigSnippet(
{
pipelines: [
{
Expand All @@ -308,14 +307,11 @@ export async function createPipelineHandler(
],
},
config.configPath
)}
`);
)
);
}
if (args.enableHttp) {
logger.log(dedent`
Send data to your pipelines HTTP endpoint:
curl "${pipeline.endpoint}" -d '[{"foo": "bar"}]'
`);
logger.log(`\nSend data to your pipelines HTTP endpoint:\n`);
logger.log(` curl "${pipeline.endpoint}" -d '[{"foo": "bar"}]'\n`);
}
}

0 comments on commit c70d322

Please sign in to comment.