Skip to content

Commit 8195d2d

Browse files
committed
add test
1 parent 3c7b9ae commit 8195d2d

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

packages/wrangler/src/__tests__/config/configuration.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2421,6 +2421,44 @@ describe("normalizeAndValidateConfig()", () => {
24212421
);
24222422
}
24232423
});
2424+
2425+
it("should error for invalid container app fields", () => {
2426+
const { diagnostics } = normalizeAndValidateConfig(
2427+
{
2428+
name: "test-worker",
2429+
containers: [
2430+
{
2431+
image: "something",
2432+
class_name: "test-class",
2433+
rollout_kind: "invalid",
2434+
instance_type: "invalid",
2435+
max_instances: "invalid",
2436+
image_build_context: 123,
2437+
image_vars: "invalid",
2438+
scheduling_policy: "invalid",
2439+
unknown_field: "value",
2440+
},
2441+
],
2442+
} as unknown as RawConfig,
2443+
undefined,
2444+
undefined,
2445+
{ env: undefined }
2446+
);
2447+
2448+
expect(diagnostics.renderWarnings()).toMatchInlineSnapshot(`
2449+
"Processing wrangler configuration:
2450+
- Unexpected fields found in containers field: \\"unknown_field\\""
2451+
`);
2452+
expect(diagnostics.renderErrors()).toMatchInlineSnapshot(`
2453+
"Processing wrangler configuration:
2454+
- Expected \\"containers.rollout_kind\\" field to be one of [\\"full_auto\\",\\"full_manual\\",\\"none\\"] but got \\"invalid\\".
2455+
- Expected \\"containers.instance_type\\" field to be one of [\\"dev\\",\\"basic\\",\\"standard\\"] but got \\"invalid\\".
2456+
- Expected \\"containers.max_instances\\" to be of type number but got \\"invalid\\".
2457+
- Expected \\"containers.image_build_context\\" to be of type string but got 123.
2458+
- Expected \\"containers.image_vars\\" to be of type object but got \\"invalid\\".
2459+
- Expected \\"containers.scheduling_policy\\" field to be one of [\\"regional\\",\\"moon\\",\\"default\\"] but got \\"invalid\\"."
2460+
`);
2461+
});
24242462
});
24252463

24262464
describe("[kv_namespaces]", () => {

0 commit comments

Comments
 (0)