@@ -20,6 +20,7 @@ const workerName = generateResourceName();
2020describe ( "provisioning" , { timeout : TIMEOUT } , ( ) => {
2121 let deployedUrl : string ;
2222 let kvId : string ;
23+ let kvId2 : string ;
2324 let d1Id : string ;
2425 const helper = new WranglerE2ETestHelper ( ) ;
2526
@@ -81,16 +82,13 @@ describe("provisioning", { timeout: TIMEOUT }, () => {
8182 - R2
8283 Provisioning KV (KV Namespace)...
8384 🌀 Creating new KV Namespace "tmp-e2e-worker-00000000-0000-0000-0000-000000000000-kv"...
84- ✨ KV provisioned with tmp-e2e-worker-00000000-0000-0000-0000-000000000000-kv
85- --------------------------------------
85+ ✨ KV provisioned 🎉
8686 Provisioning D1 (D1 Database)...
8787 🌀 Creating new D1 Database "tmp-e2e-worker-00000000-0000-0000-0000-000000000000-d1"...
88- ✨ D1 provisioned with tmp-e2e-worker-00000000-0000-0000-0000-000000000000-d1
89- --------------------------------------
88+ ✨ D1 provisioned 🎉
9089 Provisioning R2 (R2 Bucket)...
9190 🌀 Creating new R2 Bucket "tmp-e2e-worker-00000000-0000-0000-0000-000000000000-r2"...
92- ✨ R2 provisioned with tmp-e2e-worker-00000000-0000-0000-0000-000000000000-r2
93- --------------------------------------
91+ ✨ R2 provisioned 🎉
9492 🎉 All resources provisioned, continuing with deployment...
9593 Your worker has access to the following bindings:
9694 - KV Namespaces:
@@ -157,6 +155,52 @@ describe("provisioning", { timeout: TIMEOUT }, () => {
157155 expect ( text ) . toMatchInlineSnapshot ( '"Hello World!"' ) ;
158156 } ) ;
159157
158+ it ( "can inherit and provision resources on version upload" , async ( ) => {
159+ await helper . seed ( {
160+ "wrangler.toml" : dedent `
161+ name = "${ workerName } "
162+ main = "src/index.ts"
163+ compatibility_date = "2023-01-01"
164+
165+ [[r2_buckets]]
166+ binding = "R2"
167+
168+ [[kv_namespaces]]
169+ binding = "KV2"
170+ ` ,
171+ } ) ;
172+ const worker = helper . runLongLived (
173+ `wrangler versions upload --x-provision`
174+ ) ;
175+ await worker . exitCode ;
176+ const output = await worker . output ;
177+ expect ( normalize ( output ) ) . toMatchInlineSnapshot ( `
178+ "Total Upload: xx KiB / gzip: xx KiB
179+ The following bindings need to be provisioned:
180+ - KV Namespaces:
181+ - KV2
182+ Provisioning KV2 (KV Namespace)...
183+ 🌀 Creating new KV Namespace "tmp-e2e-worker-00000000-0000-0000-0000-000000000000-kv2"...
184+ ✨ KV2 provisioned 🎉
185+ 🎉 All resources provisioned, continuing with deployment...
186+ Worker Startup Time: (TIMINGS)
187+ Your worker has access to the following bindings:
188+ - KV Namespaces:
189+ - KV2: 00000000000000000000000000000000
190+ - R2 Buckets:
191+ - R2
192+ Uploaded tmp-e2e-worker-00000000-0000-0000-0000-000000000000 (TIMINGS)
193+ Worker Version ID: 00000000-0000-0000-0000-000000000000
194+ Version Preview URL: https://tmp-e2e-worker-PREVIEW-URL.SUBDOMAIN.workers.dev
195+ To deploy this version to production traffic use the command wrangler versions deploy
196+ Changes to non-versioned settings (config properties 'logpush' or 'tail_consumers') take effect after your next deployment using the command wrangler versions deploy
197+ Changes to triggers (routes, custom domains, cron schedules, etc) must be applied with the command wrangler triggers deploy"
198+ ` ) ;
199+ const kvMatch = output . match ( / - K V 2 : (?< kv > [ 0 - 9 a - f ] { 32 } ) / ) ;
200+ assert ( kvMatch ?. groups ) ;
201+ kvId2 = kvMatch . groups . kv ;
202+ } ) ;
203+
160204 afterAll ( async ( ) => {
161205 // we need to add d1 back into the config because otherwise wrangler will
162206 // call the api for all 5000 or so db's the e2e test account has
@@ -188,6 +232,9 @@ describe("provisioning", { timeout: TIMEOUT }, () => {
188232 output = await helper . run (
189233 `wrangler kv namespace delete --namespace-id ${ kvId } `
190234 ) ;
235+ output = await helper . run (
236+ `wrangler kv namespace delete --namespace-id ${ kvId2 } `
237+ ) ;
191238 expect ( output . stdout ) . toContain ( `Deleted KV namespace` ) ;
192239 } , TIMEOUT ) ;
193240} ) ;
0 commit comments