Skip to content

Commit 814f56d

Browse files
committed
fix tests
1 parent dbebdcd commit 814f56d

File tree

2 files changed

+65
-130
lines changed

2 files changed

+65
-130
lines changed

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

Lines changed: 60 additions & 129 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
});
@@ -658,107 +655,41 @@ describe("versions view", () => {
658655
Source: API 📡
659656
Tag: -
660657
Message: -
661-
------------------------------------------------------------
658+
662659
Handlers: fetch, queue
663660
Compatibility Date: 2000-00-00
664661
Compatibility Flags: flag_1, flag_2
665-
------------------------- bindings -------------------------
666-
[ai]
667-
binding = AI
668-
669-
[[analytics_engine_datasets]]
670-
binding = AE
671-
dataset = datset
672-
673-
[browser]
674-
binding = \\"BROWSER\\"
675-
676-
[[d1_databases]]
677-
binding = \\"D1\\"
678-
database_id = \\"d1-id\\"
679-
680-
[[dispatch_namespaces]]
681-
binding = \\"WFP\\"
682-
namespce = \\"wfp-namespace\\"
683-
684-
[[dispatch_namespaces]]
685-
binding = \\"WFP_2\\"
686-
namespce = \\"wfp-namespace\\"
687-
outbound = { service = \\"outbound-worker\\" }
688-
689-
[[dispatch_namespaces]]
690-
binding = \\"WFP_3\\"
691-
namespce = \\"wfp-namespace\\"
692-
outbound = { service = \\"outbound-worker\\", parameters = [paramOne, paramTwo] }
693-
694-
[[durable_objects.bindings]]
695-
name = \\"DO\\"
696-
class_name = \\"DurableObject\\"
697-
698-
[[durable_objects.bindings]]
699-
name = \\"DO_2\\"
700-
class_name = \\"DurableObject\\"
701-
script_name = \\"other-worker\\"
702-
703-
[[hyperdrive]]
704-
binding = \\"HYPERDRIVE\\"
705-
id = \\"hyperdrive-id\\"
706-
707-
[[kv_namespaces]]
708-
binding = \\"KV\\"
709-
id = \\"kv-id\\"
710-
711-
[[mtls_certificates]]
712-
binding = \\"MTLS\\"
713-
certificate_id = \\"mtls-id\\"
714-
715-
[[queues.producers]]
716-
binding = \\"QUEUE\\"
717-
queue = \\"queue\\"
718-
719-
[[queues.producers]]
720-
binding = \\"QUEUE_2\\"
721-
queue = \\"queue\\"
722-
delivery_delay = 60
723-
724-
[[r2_buckets]]
725-
binding = \\"R2\\"
726-
bucket_name = \\"r2-bucket\\"
727-
728-
[[r2_buckets]]
729-
binding = \\"R2_2\\"
730-
bucket_name = \\"r2-bucket\\"
731-
jurisdiction = \\"eu\\"
732-
733-
[[send_email]]
734-
name = \\"MAIL\\"
735-
736-
[[send_email]]
737-
name = \\"MAIL_2\\"
738-
destination_address = \\"[email protected]\\"
739-
740-
[[send_email]]
741-
name = \\"MAIL_3\\"
742-
destination_address = \\"[email protected]\\"
743-
allowed_destination_addresses = [\\"[email protected]\\", \\"[email protected]\\"]
744-
allowed_sender_addresses = [\\"[email protected]\\", \\"[email protected]\\"]
745-
746-
[[services]]
747-
binding = \\"SERVICE\\"
748-
service = \\"SERVICE\\"
749-
750-
[[services]]
751-
binding = \\"SERVICE_2\\"
752-
service = \\"SERVICE_2\\"
753-
entrypoint = \\"Enterypoint\\"
754-
755-
[[vectorize]]
756-
binding = \\"VECTORIZE\\"
757-
index_name = \\"index\\"
758-
759-
[version_metadata]
760-
binding = \\"VERSION_METADATA\\"
761-
662+
"
663+
`);
664+
expect(cnsl.out).toMatchInlineSnapshot(`
665+
"
666+
⛅️ wrangler x.x.x
667+
──────────────────
668+
Your Worker has access to the following bindings:
669+
Binding Resource
670+
env.DO (DurableObject) Durable Object
671+
env.DO_2 (DurableObject, defined in other-worker) Durable Object
672+
env.KV (kv-id) KV Namespace
673+
env.MAIL (unrestricted) Send Email
674+
env.MAIL_2 ([email protected]) Send Email
675+
env.MAIL_3 ([email protected]) Send Email
676+
env.QUEUE (queue) Queue
677+
env.QUEUE_2 (queue) Queue
678+
env.D1 (d1-id) D1 Database
679+
env.VECTORIZE (index) Vectorize Index
680+
env.HYPERDRIVE (hyperdrive-id) Hyperdrive Config
681+
env.R2 (r2-bucket) R2 Bucket
682+
env.R2_2 (r2-bucket (eu)) R2 Bucket
683+
env.SERVICE (worker) Worker
684+
env.SERVICE_2 (worker#Enterypoint) Worker
685+
env.AE (datset) Analytics Engine Dataset
686+
env.BROWSER Browser
687+
env.AI AI
688+
env.VERSION_METADATA Worker Version Metadata
689+
env.WFP (wfp-namespace) Dispatch Namespace
690+
env.WFP_2 (wfp-namespace) Dispatch Namespace
691+
env.WFP_3 (wfp-namespace) Dispatch Namespace
692+
env.MTLS (mtls-id) mTLS Certificate
762693
"
763694
`);
764695
});

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,11 @@ export async function convertBindingsToCfWorkerInitBindings(
432432
bindings.r2_buckets.push({ ...binding, binding: name });
433433
} else if (binding.type === "d1") {
434434
bindings.d1_databases ??= [];
435-
bindings.d1_databases.push({ ...binding, binding: name });
435+
bindings.d1_databases.push({
436+
...binding,
437+
binding: name,
438+
database_id: "id" in binding ? binding.id : binding.database_id,
439+
});
436440
} else if (binding.type === "vectorize") {
437441
bindings.vectorize ??= [];
438442
bindings.vectorize.push({ ...binding, binding: name });

0 commit comments

Comments
 (0)