Skip to content

Commit 17cba03

Browse files
committed
add test for wrangler deploy
1 parent cbdba1b commit 17cba03

File tree

1 file changed

+85
-0
lines changed

1 file changed

+85
-0
lines changed

packages/wrangler/src/__tests__/containers/deploy.test.ts

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,91 @@ describe("wrangler deploy with containers", () => {
306306
`);
307307
});
308308

309+
it("should be able to deploy a new container with custom instance limits (instance_type)", async () => {
310+
// note no docker commands have been mocked here!
311+
mockGetVersion("Galaxy-Class");
312+
writeWranglerConfig({
313+
...DEFAULT_DURABLE_OBJECTS,
314+
containers: [
315+
{
316+
...DEFAULT_CONTAINER_FROM_REGISTRY,
317+
instance_type: {
318+
vcpu: 1,
319+
memory_mib: 1000,
320+
disk_mb: 2000,
321+
},
322+
},
323+
],
324+
});
325+
326+
mockGetApplications([]);
327+
328+
mockCreateApplication({
329+
name: "my-container",
330+
max_instances: 10,
331+
scheduling_policy: SchedulingPolicy.DEFAULT,
332+
configuration: {
333+
image: "docker.io/hello:world",
334+
disk: {
335+
size_mb: 2000,
336+
},
337+
vcpu: 1,
338+
memory_mib: 1000,
339+
},
340+
});
341+
342+
await runWrangler("deploy index.js");
343+
344+
expect(std.out).toMatchInlineSnapshot(`
345+
"Total Upload: xx KiB / gzip: xx KiB
346+
Worker Startup Time: 100 ms
347+
Your Worker has access to the following bindings:
348+
Binding Resource
349+
env.EXAMPLE_DO_BINDING (ExampleDurableObject) Durable Object
350+
351+
Uploaded test-name (TIMINGS)
352+
Deployed test-name triggers (TIMINGS)
353+
https://test-name.test-sub-domain.workers.dev
354+
Current Version ID: Galaxy-Class"
355+
`);
356+
expect(std.err).toMatchInlineSnapshot(`""`);
357+
358+
expect(cliStd.stdout).toMatchInlineSnapshot(`
359+
"╭ Deploy a container application deploy changes to your application
360+
361+
│ Container application changes
362+
363+
├ NEW my-container
364+
365+
│ [[containers]]
366+
│ name = \\"my-container\\"
367+
│ scheduling_policy = \\"default\\"
368+
│ instances = 0
369+
│ max_instances = 10
370+
371+
│ [containers.configuration]
372+
│ image = \\"docker.io/hello:world\\"
373+
│ memory_mib = 1_000
374+
│ vcpu = 1
375+
376+
│ [containers.configuration.disk]
377+
│ size_mb = 2_000
378+
379+
│ [containers.constraints]
380+
│ tier = 1
381+
382+
│ [containers.durable_objects]
383+
│ namespace_id = \\"1\\"
384+
385+
386+
│ SUCCESS Created application my-container (Application ID: undefined)
387+
388+
╰ Applied changes
389+
390+
"
391+
`);
392+
});
393+
309394
it("should resolve the docker build context path based on the dockerfile location, if image_build_context is not provided", async () => {
310395
vi.stubEnv("WRANGLER_DOCKER_BIN", "/usr/bin/docker");
311396
mockGetVersion("Galaxy-Class");

0 commit comments

Comments
 (0)