-
Notifications
You must be signed in to change notification settings - Fork 667
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed versions upload printing duplicate bindings (#6530)
- Loading branch information
Showing
3 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"wrangler": patch | ||
--- | ||
|
||
fix: fixed `wrangler versions upload` printing bindings twice |
103 changes: 103 additions & 0 deletions
103
packages/wrangler/src/__tests__/versions/versions.upload.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
import * as fs from "node:fs"; | ||
import { http, HttpResponse } from "msw"; | ||
import { mockAccountId, mockApiToken } from "../helpers/mock-account-id"; | ||
import { mockConsoleMethods } from "../helpers/mock-console"; | ||
import { useMockIsTTY } from "../helpers/mock-istty"; | ||
import { mockSubDomainRequest } from "../helpers/mock-workers-subdomain"; | ||
import { msw } from "../helpers/msw"; | ||
import { runWrangler } from "../helpers/run-wrangler"; | ||
import { writeWorkerSource } from "../helpers/write-worker-source"; | ||
import { writeWranglerToml } from "../helpers/write-wrangler-toml"; | ||
|
||
describe("versions upload", () => { | ||
mockAccountId(); | ||
mockApiToken(); | ||
const { setIsTTY } = useMockIsTTY(); | ||
const std = mockConsoleMethods(); | ||
|
||
test("should print bindings & startup time on versions upload", async () => { | ||
msw.use( | ||
http.get( | ||
`*/accounts/:accountId/workers/services/:scriptName`, | ||
({ params }) => { | ||
expect(params.scriptName).toEqual("test-worker"); | ||
|
||
return HttpResponse.json( | ||
{ | ||
success: true, | ||
errors: [], | ||
messages: [], | ||
result: { | ||
default_environment: { | ||
script: { | ||
last_deployed_from: "wrangler", | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ status: 200 } | ||
); | ||
}, | ||
{ once: true } | ||
), | ||
http.post( | ||
`*/accounts/:accountId/workers/scripts/:scriptName/versions`, | ||
({ params }) => { | ||
expect(params.scriptName).toEqual("test-worker"); | ||
|
||
return HttpResponse.json( | ||
{ | ||
success: true, | ||
errors: [], | ||
messages: [], | ||
result: { | ||
id: "51e4886e-2db7-4900-8d38-fbfecfeab993", | ||
startup_time_ms: 500, | ||
}, | ||
}, | ||
{ status: 200 } | ||
); | ||
}, | ||
{ once: true } | ||
) | ||
); | ||
mockSubDomainRequest(); | ||
|
||
// Setup | ||
fs.mkdirSync("./versions-upload-test-worker", { recursive: true }); | ||
writeWranglerToml({ | ||
name: "test-worker", | ||
main: "./index.js", | ||
vars: { | ||
TEST: "test-string", | ||
JSON: { | ||
abc: "def", | ||
bool: true, | ||
}, | ||
}, | ||
kv_namespaces: [{ binding: "KV", id: "xxxx-xxxx-xxxx-xxxx" }], | ||
}); | ||
writeWorkerSource(); | ||
setIsTTY(false); | ||
|
||
const result = runWrangler("versions upload --x-versions"); | ||
|
||
await expect(result).resolves.toBeUndefined(); | ||
|
||
expect(std.out).toMatchInlineSnapshot(` | ||
"Total Upload: xx KiB / gzip: xx KiB | ||
Worker Startup Time: 500 ms | ||
Your worker has access to the following bindings: | ||
- KV Namespaces: | ||
- KV: xxxx-xxxx-xxxx-xxxx | ||
- Vars: | ||
- TEST: \\"test-string\\" | ||
- JSON: { | ||
\\"abc\\": \\"def\\", | ||
\\"bool\\": true | ||
} | ||
Worker Version ID: 51e4886e-2db7-4900-8d38-fbfecfeab993 | ||
Uploaded test-worker (TIMINGS)" | ||
`); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters