Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 73 additions & 31 deletions packages/wrangler/src/__tests__/cloudchamber/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,6 @@ import { runWrangler } from "../helpers/run-wrangler";
import { mockAccount, setWranglerConfig } from "./utils";
import type { SSHPublicKeyItem } from "@cloudflare/containers-shared";

const MOCK_DEPLOYMENTS_COMPLEX_RESPONSE = `
"{
\\"id\\": \\"1\\",
\\"type\\": \\"default\\",
\\"created_at\\": \\"123\\",
\\"account_id\\": \\"123\\",
\\"vcpu\\": 4,
\\"memory\\": \\"400MB\\",
\\"memory_mib\\": 400,
\\"version\\": 1,
\\"image\\": \\"hello\\",
\\"location\\": {
\\"name\\": \\"sfo06\\",
\\"enabled\\": true
},
\\"network\\": {
\\"mode\\": \\"public\\",
\\"ipv4\\": \\"1.1.1.1\\"
},
\\"placements_ref\\": \\"http://ref\\",
\\"node_group\\": \\"metal\\"
}"
`;

function mockDeploymentPost() {
msw.use(
http.post(
Expand Down Expand Up @@ -103,7 +79,7 @@ describe("cloudchamber create", () => {
expect(std.out).toMatchInlineSnapshot(`
"wrangler cloudchamber create

Create a new deployment
Create a new deployment [alpha]

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
Expand Down Expand Up @@ -230,7 +206,29 @@ describe("cloudchamber create", () => {
);
// so testing the actual UI will be harder than expected
// TODO: think better on how to test UI actions
expect(std.out).toMatchInlineSnapshot(MOCK_DEPLOYMENTS_COMPLEX_RESPONSE);
expect(std.out).toMatchInlineSnapshot(`
"{
\\"id\\": \\"1\\",
\\"type\\": \\"default\\",
\\"created_at\\": \\"123\\",
\\"account_id\\": \\"123\\",
\\"vcpu\\": 4,
\\"memory\\": \\"400MB\\",
\\"memory_mib\\": 400,
\\"version\\": 1,
\\"image\\": \\"hello\\",
\\"location\\": {
\\"name\\": \\"sfo06\\",
\\"enabled\\": true
},
\\"network\\": {
\\"mode\\": \\"public\\",
\\"ipv4\\": \\"1.1.1.1\\"
},
\\"placements_ref\\": \\"http://ref\\",
\\"node_group\\": \\"metal\\"
}"
`);
});

it("should create deployment with instance type (detects no interactivity)", async () => {
Expand Down Expand Up @@ -274,7 +272,29 @@ describe("cloudchamber create", () => {
await runWrangler(
"cloudchamber create --var HELLO:WORLD --var YOU:CONQUERED"
);
expect(std.out).toMatchInlineSnapshot(MOCK_DEPLOYMENTS_COMPLEX_RESPONSE);
expect(std.out).toMatchInlineSnapshot(`
"{
\\"id\\": \\"1\\",
\\"type\\": \\"default\\",
\\"created_at\\": \\"123\\",
\\"account_id\\": \\"123\\",
\\"vcpu\\": 4,
\\"memory\\": \\"400MB\\",
\\"memory_mib\\": 400,
\\"version\\": 1,
\\"image\\": \\"hello\\",
\\"location\\": {
\\"name\\": \\"sfo06\\",
\\"enabled\\": true
},
\\"network\\": {
\\"mode\\": \\"public\\",
\\"ipv4\\": \\"1.1.1.1\\"
},
\\"placements_ref\\": \\"http://ref\\",
\\"node_group\\": \\"metal\\"
}"
`);
expect(std.err).toMatchInlineSnapshot(`""`);
});

Expand Down Expand Up @@ -349,7 +369,29 @@ describe("cloudchamber create", () => {
await runWrangler(
"cloudchamber create --image hello:world --location sfo06 --var HELLO:WORLD --var YOU:CONQUERED --all-ssh-keys --ipv4"
);
expect(std.out).toMatchInlineSnapshot(MOCK_DEPLOYMENTS_COMPLEX_RESPONSE);
expect(std.out).toMatchInlineSnapshot(`
"{
\\"id\\": \\"1\\",
\\"type\\": \\"default\\",
\\"created_at\\": \\"123\\",
\\"account_id\\": \\"123\\",
\\"vcpu\\": 4,
\\"memory\\": \\"400MB\\",
\\"memory_mib\\": 400,
\\"version\\": 1,
\\"image\\": \\"hello\\",
\\"location\\": {
\\"name\\": \\"sfo06\\",
\\"enabled\\": true
},
\\"network\\": {
\\"mode\\": \\"public\\",
\\"ipv4\\": \\"1.1.1.1\\"
},
\\"placements_ref\\": \\"http://ref\\",
\\"node_group\\": \\"metal\\"
}"
`);
});

it("can't create deployment due to lack of fields (json)", async () => {
Expand All @@ -364,8 +406,8 @@ describe("cloudchamber create", () => {
// so testing the actual UI will be harder than expected
// TODO: think better on how to test UI actions
expect(std.out).toMatchInlineSnapshot(`
"
If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
`);
"
If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
`);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe("cloudchamber curl", () => {
expect(helpStd.out).toMatchInlineSnapshot(`
"wrangler cloudchamber curl <path>

Send a request to an arbitrary Cloudchamber endpoint
Send a request to an arbitrary Cloudchamber endpoint [alpha]

POSITIONALS
path [string] [required] [default: \\"/\\"]
Expand Down
10 changes: 5 additions & 5 deletions packages/wrangler/src/__tests__/cloudchamber/delete.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ describe("cloudchamber delete", () => {
expect(std.out).toMatchInlineSnapshot(`
"wrangler cloudchamber delete [deploymentId]

Delete an existing deployment that is running in the Cloudflare edge
Delete an existing deployment that is running in the Cloudflare edge [alpha]

POSITIONALS
deploymentId deployment you want to delete [string]
deploymentId Deployment you want to delete [string]

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
Expand Down Expand Up @@ -98,8 +98,8 @@ describe("cloudchamber delete", () => {
// so testing the actual UI will be harder than expected
// TODO: think better on how to test UI actions
expect(std.out).toMatchInlineSnapshot(`
"
If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
`);
"
If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose"
`);
});
});
14 changes: 7 additions & 7 deletions packages/wrangler/src/__tests__/cloudchamber/images.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ describe("cloudchamber image", () => {
expect(std.out).toMatchInlineSnapshot(`
"wrangler cloudchamber registries

Configure registries via Cloudchamber
Configure registries via Cloudchamber [alpha]

COMMANDS
wrangler cloudchamber registries configure Configure Cloudchamber to pull from specific registries
wrangler cloudchamber registries credentials [domain] get a temporary password for a specific domain
wrangler cloudchamber registries remove [domain] removes the registry at the given domain
wrangler cloudchamber registries list list registries configured for this account
wrangler cloudchamber registries configure Configure Cloudchamber to pull from specific registries [alpha]
wrangler cloudchamber registries credentials <domain> Get a temporary password for a specific domain [alpha]
wrangler cloudchamber registries remove <domain> Remove the registry at the given domain [alpha]
wrangler cloudchamber registries list List registries configured for this account [alpha]

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
Expand Down Expand Up @@ -182,7 +182,7 @@ describe("cloudchamber image list", () => {
expect(std.out).toMatchInlineSnapshot(`
"wrangler cloudchamber images list

List images in the Cloudflare managed registry
List images in the Cloudflare managed registry [alpha]

GLOBAL FLAGS
-c, --config Path to Wrangler configuration file [string]
Expand Down Expand Up @@ -434,7 +434,7 @@ describe("cloudchamber image delete", () => {
expect(std.out).toMatchInlineSnapshot(`
"wrangler cloudchamber images delete <image>

Remove an image from the Cloudflare managed registry
Remove an image from the Cloudflare managed registry [alpha]

POSITIONALS
image Image and tag to delete, of the form IMAGE:TAG [string] [required]
Expand Down
Loading
Loading