|
1 | 1 | import path from "node:path"; |
2 | 2 | import { readConfig } from "../config"; |
3 | 3 | import { normalizeAndValidateConfig } from "../config/validation"; |
| 4 | +import { run } from "../experimental-flags"; |
4 | 5 | import { normalizeString } from "./helpers/normalize"; |
5 | 6 | import { runInTempDir } from "./helpers/run-in-tmp"; |
6 | 7 | import { writeWranglerConfig } from "./helpers/write-wrangler-config"; |
@@ -2324,6 +2325,26 @@ describe("normalizeAndValidateConfig()", () => { |
2324 | 2325 | - \\"kv_namespaces[4]\\" bindings should have a string \\"id\\" field but got {\\"binding\\":\\"VALID\\",\\"id\\":\\"\\"}." |
2325 | 2326 | `); |
2326 | 2327 | }); |
| 2328 | + |
| 2329 | + it("should allow the id field to be omitted when the RESOURCES_PROVISION experimental flag is enabled", () => { |
| 2330 | + const { diagnostics } = run( |
| 2331 | + { |
| 2332 | + RESOURCES_PROVISION: true, |
| 2333 | + FILE_BASED_REGISTRY: false, |
| 2334 | + }, |
| 2335 | + () => |
| 2336 | + normalizeAndValidateConfig( |
| 2337 | + { |
| 2338 | + kv_namespaces: [{ binding: "VALID" }], |
| 2339 | + } as unknown as RawConfig, |
| 2340 | + undefined, |
| 2341 | + { env: undefined } |
| 2342 | + ) |
| 2343 | + ); |
| 2344 | + |
| 2345 | + expect(diagnostics.hasWarnings()).toBe(false); |
| 2346 | + expect(diagnostics.hasErrors()).toBe(false); |
| 2347 | + }); |
2327 | 2348 | }); |
2328 | 2349 |
|
2329 | 2350 | it("should error if send_email.bindings are not valid", () => { |
@@ -2452,6 +2473,26 @@ describe("normalizeAndValidateConfig()", () => { |
2452 | 2473 | - \\"d1_databases[4]\\" bindings must have a \\"database_id\\" field but got {\\"binding\\":\\"VALID\\",\\"id\\":\\"\\"}." |
2453 | 2474 | `); |
2454 | 2475 | }); |
| 2476 | + |
| 2477 | + it("should allow the database_id field to be omitted when the RESOURCES_PROVISION experimental flag is enabled", () => { |
| 2478 | + const { diagnostics } = run( |
| 2479 | + { |
| 2480 | + RESOURCES_PROVISION: true, |
| 2481 | + FILE_BASED_REGISTRY: false, |
| 2482 | + }, |
| 2483 | + () => |
| 2484 | + normalizeAndValidateConfig( |
| 2485 | + { |
| 2486 | + d1_databases: [{ binding: "VALID" }], |
| 2487 | + } as unknown as RawConfig, |
| 2488 | + undefined, |
| 2489 | + { env: undefined } |
| 2490 | + ) |
| 2491 | + ); |
| 2492 | + |
| 2493 | + expect(diagnostics.hasWarnings()).toBe(false); |
| 2494 | + expect(diagnostics.hasErrors()).toBe(false); |
| 2495 | + }); |
2455 | 2496 | }); |
2456 | 2497 |
|
2457 | 2498 | describe("[hyperdrive]", () => { |
@@ -2746,6 +2787,26 @@ describe("normalizeAndValidateConfig()", () => { |
2746 | 2787 | - \\"r2_buckets[4]\\" bindings should have a string \\"bucket_name\\" field but got {\\"binding\\":\\"R2_BINDING_1\\",\\"bucket_name\\":\\"\\"}." |
2747 | 2788 | `); |
2748 | 2789 | }); |
| 2790 | + |
| 2791 | + it("should allow the bucket_name field to be omitted when the RESOURCES_PROVISION experimental flag is enabled", () => { |
| 2792 | + const { diagnostics } = run( |
| 2793 | + { |
| 2794 | + RESOURCES_PROVISION: true, |
| 2795 | + FILE_BASED_REGISTRY: false, |
| 2796 | + }, |
| 2797 | + () => |
| 2798 | + normalizeAndValidateConfig( |
| 2799 | + { |
| 2800 | + d1_databases: [{ binding: "VALID" }], |
| 2801 | + } as unknown as RawConfig, |
| 2802 | + undefined, |
| 2803 | + { env: undefined } |
| 2804 | + ) |
| 2805 | + ); |
| 2806 | + |
| 2807 | + expect(diagnostics.hasWarnings()).toBe(false); |
| 2808 | + expect(diagnostics.hasErrors()).toBe(false); |
| 2809 | + }); |
2749 | 2810 | }); |
2750 | 2811 |
|
2751 | 2812 | describe("[services]", () => { |
|
0 commit comments