Skip to content

Commit 8ab18a0

Browse files
committed
fix tests
1 parent 2f706d1 commit 8ab18a0

File tree

2 files changed

+65
-129
lines changed

2 files changed

+65
-129
lines changed

packages/wrangler/src/__tests__/versions/versions.view.test.ts

Lines changed: 60 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -71,23 +71,23 @@ describe("versions view", () => {
7171
Source: Upload
7272
Tag: -
7373
Message: -
74-
------------------------------------------------------------
74+
7575
Handlers: fetch, scheduled
7676
Compatibility Date: 2020-01-01
7777
Compatibility Flags: test, flag
78-
------------------------- bindings -------------------------
79-
[[analytics_engine_datasets]]
80-
binding = ANALYTICS
81-
dataset = analytics_dataset
82-
83-
[[kv_namespaces]]
84-
binding = \\"KV\\"
85-
id = \\"kv-namespace-id\\"
86-
8778
"
8879
`);
8980

90-
expect(cnsl.out).toMatch(/ wrangler/);
81+
expect(cnsl.out).toMatchInlineSnapshot(`
82+
"
83+
⛅️ wrangler x.x.x
84+
──────────────────
85+
Your Worker has access to the following bindings:
86+
Binding Resource
87+
env.KV (kv-namespace-id) KV Namespace
88+
env.ANALYTICS (analytics_dataset) Analytics Engine Dataset
89+
"
90+
`);
9191

9292
expect(normalizeOutput(std.err)).toMatchInlineSnapshot(`""`);
9393
});
@@ -186,19 +186,20 @@ describe("versions view", () => {
186186
Source: Upload
187187
Tag: -
188188
Message: -
189-
------------------------------------------------------------
189+
190190
Handlers: fetch, scheduled
191191
Compatibility Date: 2020-01-01
192192
Compatibility Flags: test, flag
193-
------------------------- bindings -------------------------
194-
[[analytics_engine_datasets]]
195-
binding = ANALYTICS
196-
dataset = analytics_dataset
197-
198-
[[kv_namespaces]]
199-
binding = \\"KV\\"
200-
id = \\"kv-namespace-id\\"
201-
193+
"
194+
`);
195+
expect(cnsl.out).toMatchInlineSnapshot(`
196+
"
197+
⛅️ wrangler x.x.x
198+
──────────────────
199+
Your Worker has access to the following bindings:
200+
Binding Resource
201+
env.KV (kv-namespace-id) KV Namespace
202+
env.ANALYTICS (analytics_dataset) Analytics Engine Dataset
202203
"
203204
`);
204205

@@ -320,7 +321,7 @@ describe("versions view", () => {
320321
Source: API 📡
321322
Tag: -
322323
Message: -
323-
------------------------------------------------------------
324+
324325
Handlers: fetch, queue
325326
"
326327
`);
@@ -367,7 +368,7 @@ describe("versions view", () => {
367368
Source: API 📡
368369
Tag: -
369370
Message: -
370-
------------------------------------------------------------
371+
371372
Handlers: fetch, queue
372373
Compatibility Date: 2000-00-00
373374
"
@@ -416,7 +417,7 @@ describe("versions view", () => {
416417
Source: API 📡
417418
Tag: -
418419
Message: -
419-
------------------------------------------------------------
420+
420421
Handlers: fetch, queue
421422
Compatibility Date: 2000-00-00
422423
Compatibility Flags: flag_1, flag_2
@@ -469,11 +470,11 @@ describe("versions view", () => {
469470
Source: API 📡
470471
Tag: -
471472
Message: -
472-
------------------------------------------------------------
473+
473474
Handlers: fetch, queue
474475
Compatibility Date: 2000-00-00
475476
Compatibility Flags: flag_1, flag_2
476-
------------------------- secrets -------------------------
477+
Secrets:
477478
Secret Name: SECRET_ONE
478479
Secret Name: SECRET_TWO
479480
"
@@ -525,14 +526,10 @@ describe("versions view", () => {
525526
Source: API 📡
526527
Tag: -
527528
Message: -
528-
------------------------------------------------------------
529+
529530
Handlers: fetch, queue
530531
Compatibility Date: 2000-00-00
531532
Compatibility Flags: flag_1, flag_2
532-
------------------------- bindings -------------------------
533-
[vars]
534-
VAR_ONE = \\"var-one\\"
535-
VAR_TWO = \\"var-one\\"
536533
"
537534
`);
538535
});
@@ -657,106 +654,41 @@ describe("versions view", () => {
657654
Source: API 📡
658655
Tag: -
659656
Message: -
660-
------------------------------------------------------------
657+
661658
Handlers: fetch, queue
662659
Compatibility Date: 2000-00-00
663660
Compatibility Flags: flag_1, flag_2
664-
------------------------- bindings -------------------------
665-
[ai]
666-
binding = AI
667-
668-
[[analytics_engine_datasets]]
669-
binding = AE
670-
dataset = datset
671-
672-
[browser]
673-
binding = \\"BROWSER\\"
674-
675-
[[d1_databases]]
676-
binding = \\"D1\\"
677-
database_id = \\"d1-id\\"
678-
679-
[[dispatch_namespaces]]
680-
binding = \\"WFP\\"
681-
namespce = \\"wfp-namespace\\"
682-
683-
[[dispatch_namespaces]]
684-
binding = \\"WFP_2\\"
685-
namespce = \\"wfp-namespace\\"
686-
outbound = { service = \\"outbound-worker\\" }
687-
688-
[[dispatch_namespaces]]
689-
binding = \\"WFP_3\\"
690-
namespce = \\"wfp-namespace\\"
691-
outbound = { service = \\"outbound-worker\\", parameters = [paramOne, paramTwo] }
692-
693-
[[durable_objects.bindings]]
694-
name = \\"DO\\"
695-
class_name = \\"DurableObject\\"
696-
697-
[[durable_objects.bindings]]
698-
name = \\"DO_2\\"
699-
class_name = \\"DurableObject\\"
700-
script_name = \\"other-worker\\"
701-
702-
[[hyperdrive]]
703-
binding = \\"HYPERDRIVE\\"
704-
id = \\"hyperdrive-id\\"
705-
706-
[[kv_namespaces]]
707-
binding = \\"KV\\"
708-
id = \\"kv-id\\"
709-
710-
[[mtls_certificates]]
711-
binding = \\"MTLS\\"
712-
certificate_id = \\"mtls-id\\"
713-
714-
[[queues.producers]]
715-
binding = \\"QUEUE\\"
716-
queue = \\"queue\\"
717-
718-
[[queues.producers]]
719-
binding = \\"QUEUE_2\\"
720-
queue = \\"queue\\"
721-
delivery_delay = 60
722-
723-
[[r2_buckets]]
724-
binding = \\"R2\\"
725-
bucket_name = \\"r2-bucket\\"
726-
727-
[[r2_buckets]]
728-
binding = \\"R2_2\\"
729-
bucket_name = \\"r2-bucket\\"
730-
jurisdiction = \\"eu\\"
731-
732-
[[send_email]]
733-
name = \\"MAIL\\"
734-
735-
[[send_email]]
736-
name = \\"MAIL_2\\"
737-
destination_address = \\"[email protected]\\"
738-
739-
[[send_email]]
740-
name = \\"MAIL_3\\"
741-
destination_address = \\"[email protected]\\"
742-
allowed_destination_addresses = [\\"[email protected]\\", \\"[email protected]\\"]
743-
744-
[[services]]
745-
binding = \\"SERVICE\\"
746-
service = \\"SERVICE\\"
747-
748-
[[services]]
749-
binding = \\"SERVICE_2\\"
750-
service = \\"SERVICE_2\\"
751-
entrypoint = \\"Enterypoint\\"
752-
753-
[[vectorize]]
754-
binding = \\"VECTORIZE\\"
755-
index_name = \\"index\\"
756-
757-
[version_metadata]
758-
binding = \\"VERSION_METADATA\\"
759-
661+
"
662+
`);
663+
expect(cnsl.out).toMatchInlineSnapshot(`
664+
"
665+
⛅️ wrangler x.x.x
666+
──────────────────
667+
Your Worker has access to the following bindings:
668+
Binding Resource
669+
env.DO (DurableObject) Durable Object
670+
env.DO_2 (DurableObject, defined in other-worker) Durable Object
671+
env.KV (kv-id) KV Namespace
672+
env.MAIL (unrestricted) Send Email
673+
env.MAIL_2 ([email protected]) Send Email
674+
env.MAIL_3 ([email protected]) Send Email
675+
env.QUEUE (queue) Queue
676+
env.QUEUE_2 (queue) Queue
677+
env.D1 (d1-id) D1 Database
678+
env.VECTORIZE (index) Vectorize Index
679+
env.HYPERDRIVE (hyperdrive-id) Hyperdrive Config
680+
env.R2 (r2-bucket) R2 Bucket
681+
env.R2_2 (r2-bucket (eu)) R2 Bucket
682+
env.SERVICE (worker) Worker
683+
env.SERVICE_2 (worker#Enterypoint) Worker
684+
env.AE (datset) Analytics Engine Dataset
685+
env.BROWSER Browser
686+
env.AI AI
687+
env.VERSION_METADATA Worker Version Metadata
688+
env.WFP (wfp-namespace) Dispatch Namespace
689+
env.WFP_2 (wfp-namespace) Dispatch Namespace
690+
env.WFP_3 (wfp-namespace) Dispatch Namespace
691+
env.MTLS (mtls-id) mTLS Certificate
760692
"
761693
`);
762694
});

packages/wrangler/src/api/startDevWorker/utils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,11 @@ export async function convertBindingsToCfWorkerInitBindings(
400400
bindings.r2_buckets.push({ ...binding, binding: name });
401401
} else if (binding.type === "d1") {
402402
bindings.d1_databases ??= [];
403-
bindings.d1_databases.push({ ...binding, binding: name });
403+
bindings.d1_databases.push({
404+
...binding,
405+
binding: name,
406+
database_id: "id" in binding ? binding.id : binding.database_id,
407+
});
404408
} else if (binding.type === "vectorize") {
405409
bindings.vectorize ??= [];
406410
bindings.vectorize.push({ ...binding, binding: name });

0 commit comments

Comments
 (0)