Skip to content

Commit 85bff0d

Browse files
committed
fix tests
1 parent 901764c commit 85bff0d

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
@@ -69,23 +69,23 @@ describe("versions view", () => {
6969
Source: Upload
7070
Tag: -
7171
Message: -
72-
------------------------------------------------------------
72+
7373
Handlers: fetch, scheduled
7474
Compatibility Date: 2020-01-01
7575
Compatibility Flags: test, flag
76-
------------------------- bindings -------------------------
77-
[[analytics_engine_datasets]]
78-
binding = ANALYTICS
79-
dataset = analytics_dataset
80-
81-
[[kv_namespaces]]
82-
binding = \\"KV\\"
83-
id = \\"kv-namespace-id\\"
84-
8576
"
8677
`);
8778

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

9090
expect(normalizeOutput(std.err)).toMatchInlineSnapshot(`""`);
9191
});
@@ -184,19 +184,20 @@ describe("versions view", () => {
184184
Source: Upload
185185
Tag: -
186186
Message: -
187-
------------------------------------------------------------
187+
188188
Handlers: fetch, scheduled
189189
Compatibility Date: 2020-01-01
190190
Compatibility Flags: test, flag
191-
------------------------- bindings -------------------------
192-
[[analytics_engine_datasets]]
193-
binding = ANALYTICS
194-
dataset = analytics_dataset
195-
196-
[[kv_namespaces]]
197-
binding = \\"KV\\"
198-
id = \\"kv-namespace-id\\"
199-
191+
"
192+
`);
193+
expect(cnsl.out).toMatchInlineSnapshot(`
194+
"
195+
⛅️ wrangler x.x.x
196+
──────────────────
197+
Your Worker has access to the following bindings:
198+
Binding Resource
199+
env.KV (kv-namespace-id) KV Namespace
200+
env.ANALYTICS (analytics_dataset) Analytics Engine Dataset
200201
"
201202
`);
202203

@@ -318,7 +319,7 @@ describe("versions view", () => {
318319
Source: API 📡
319320
Tag: -
320321
Message: -
321-
------------------------------------------------------------
322+
322323
Handlers: fetch, queue
323324
"
324325
`);
@@ -365,7 +366,7 @@ describe("versions view", () => {
365366
Source: API 📡
366367
Tag: -
367368
Message: -
368-
------------------------------------------------------------
369+
369370
Handlers: fetch, queue
370371
Compatibility Date: 2000-00-00
371372
"
@@ -414,7 +415,7 @@ describe("versions view", () => {
414415
Source: API 📡
415416
Tag: -
416417
Message: -
417-
------------------------------------------------------------
418+
418419
Handlers: fetch, queue
419420
Compatibility Date: 2000-00-00
420421
Compatibility Flags: flag_1, flag_2
@@ -467,11 +468,11 @@ describe("versions view", () => {
467468
Source: API 📡
468469
Tag: -
469470
Message: -
470-
------------------------------------------------------------
471+
471472
Handlers: fetch, queue
472473
Compatibility Date: 2000-00-00
473474
Compatibility Flags: flag_1, flag_2
474-
------------------------- secrets -------------------------
475+
Secrets:
475476
Secret Name: SECRET_ONE
476477
Secret Name: SECRET_TWO
477478
"
@@ -523,14 +524,10 @@ describe("versions view", () => {
523524
Source: API 📡
524525
Tag: -
525526
Message: -
526-
------------------------------------------------------------
527+
527528
Handlers: fetch, queue
528529
Compatibility Date: 2000-00-00
529530
Compatibility Flags: flag_1, flag_2
530-
------------------------- bindings -------------------------
531-
[vars]
532-
VAR_ONE = \\"var-one\\"
533-
VAR_TWO = \\"var-one\\"
534531
"
535532
`);
536533
});
@@ -656,107 +653,41 @@ describe("versions view", () => {
656653
Source: API 📡
657654
Tag: -
658655
Message: -
659-
------------------------------------------------------------
656+
660657
Handlers: fetch, queue
661658
Compatibility Date: 2000-00-00
662659
Compatibility Flags: flag_1, flag_2
663-
------------------------- bindings -------------------------
664-
[ai]
665-
binding = AI
666-
667-
[[analytics_engine_datasets]]
668-
binding = AE
669-
dataset = datset
670-
671-
[browser]
672-
binding = \\"BROWSER\\"
673-
674-
[[d1_databases]]
675-
binding = \\"D1\\"
676-
database_id = \\"d1-id\\"
677-
678-
[[dispatch_namespaces]]
679-
binding = \\"WFP\\"
680-
namespce = \\"wfp-namespace\\"
681-
682-
[[dispatch_namespaces]]
683-
binding = \\"WFP_2\\"
684-
namespce = \\"wfp-namespace\\"
685-
outbound = { service = \\"outbound-worker\\" }
686-
687-
[[dispatch_namespaces]]
688-
binding = \\"WFP_3\\"
689-
namespce = \\"wfp-namespace\\"
690-
outbound = { service = \\"outbound-worker\\", parameters = [paramOne, paramTwo] }
691-
692-
[[durable_objects.bindings]]
693-
name = \\"DO\\"
694-
class_name = \\"DurableObject\\"
695-
696-
[[durable_objects.bindings]]
697-
name = \\"DO_2\\"
698-
class_name = \\"DurableObject\\"
699-
script_name = \\"other-worker\\"
700-
701-
[[hyperdrive]]
702-
binding = \\"HYPERDRIVE\\"
703-
id = \\"hyperdrive-id\\"
704-
705-
[[kv_namespaces]]
706-
binding = \\"KV\\"
707-
id = \\"kv-id\\"
708-
709-
[[mtls_certificates]]
710-
binding = \\"MTLS\\"
711-
certificate_id = \\"mtls-id\\"
712-
713-
[[queues.producers]]
714-
binding = \\"QUEUE\\"
715-
queue = \\"queue\\"
716-
717-
[[queues.producers]]
718-
binding = \\"QUEUE_2\\"
719-
queue = \\"queue\\"
720-
delivery_delay = 60
721-
722-
[[r2_buckets]]
723-
binding = \\"R2\\"
724-
bucket_name = \\"r2-bucket\\"
725-
726-
[[r2_buckets]]
727-
binding = \\"R2_2\\"
728-
bucket_name = \\"r2-bucket\\"
729-
jurisdiction = \\"eu\\"
730-
731-
[[send_email]]
732-
name = \\"MAIL\\"
733-
734-
[[send_email]]
735-
name = \\"MAIL_2\\"
736-
destination_address = \\"[email protected]\\"
737-
738-
[[send_email]]
739-
name = \\"MAIL_3\\"
740-
destination_address = \\"[email protected]\\"
741-
allowed_destination_addresses = [\\"[email protected]\\", \\"[email protected]\\"]
742-
allowed_sender_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-
660+
"
661+
`);
662+
expect(cnsl.out).toMatchInlineSnapshot(`
663+
"
664+
⛅️ wrangler x.x.x
665+
──────────────────
666+
Your Worker has access to the following bindings:
667+
Binding Resource
668+
env.DO (DurableObject) Durable Object
669+
env.DO_2 (DurableObject, defined in other-worker) Durable Object
670+
env.KV (kv-id) KV Namespace
671+
env.MAIL (unrestricted) Send Email
672+
env.MAIL_2 ([email protected]) Send Email
673+
env.MAIL_3 ([email protected]) Send Email
674+
env.QUEUE (queue) Queue
675+
env.QUEUE_2 (queue) Queue
676+
env.D1 (d1-id) D1 Database
677+
env.VECTORIZE (index) Vectorize Index
678+
env.HYPERDRIVE (hyperdrive-id) Hyperdrive Config
679+
env.R2 (r2-bucket) R2 Bucket
680+
env.R2_2 (r2-bucket (eu)) R2 Bucket
681+
env.SERVICE (worker) Worker
682+
env.SERVICE_2 (worker#Enterypoint) Worker
683+
env.AE (datset) Analytics Engine Dataset
684+
env.BROWSER Browser
685+
env.AI AI
686+
env.VERSION_METADATA Worker Version Metadata
687+
env.WFP (wfp-namespace) Dispatch Namespace
688+
env.WFP_2 (wfp-namespace) Dispatch Namespace
689+
env.WFP_3 (wfp-namespace) Dispatch Namespace
690+
env.MTLS (mtls-id) mTLS Certificate
760691
"
761692
`);
762693
});

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)