@@ -120,7 +120,7 @@ describe("hyperdrive commands", () => {
120
120
121
121
expect ( std . out ) . toMatchInlineSnapshot ( `
122
122
"🚧 Creating 'test123'
123
- ✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
123
+ ✅ Created new Hyperdrive PostgreSQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
124
124
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
125
125
126
126
{
@@ -157,7 +157,7 @@ describe("hyperdrive commands", () => {
157
157
158
158
expect ( std . out ) . toMatchInlineSnapshot ( `
159
159
"🚧 Creating 'test123'
160
- ✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
160
+ ✅ Created new Hyperdrive PostgreSQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
161
161
📋 To start using your config from a Worker, add the following binding configuration to your wrangler.toml file:
162
162
163
163
[[hyperdrive]]
@@ -188,7 +188,42 @@ describe("hyperdrive commands", () => {
188
188
` ) ;
189
189
expect ( std . out ) . toMatchInlineSnapshot ( `
190
190
"🚧 Creating 'test123'
191
- ✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
191
+ ✅ Created new Hyperdrive PostgreSQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
192
+ 📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
193
+
194
+ {
195
+ \\"hyperdrive\\": [
196
+ {
197
+ \\"binding\\": \\"HYPERDRIVE\\",
198
+ \\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\"
199
+ }
200
+ ]
201
+ }"
202
+ ` ) ;
203
+ } ) ;
204
+
205
+ it ( "should handle creating a hyperdrive config for postgres without a port specified" , async ( ) => {
206
+ const reqProm = mockHyperdriveCreate ( ) ;
207
+ await runWrangler (
208
+ "hyperdrive create test123 --connection-string='mysql://test:[email protected] /neondb'"
209
+ ) ;
210
+
211
+ await expect ( reqProm ) . resolves . toMatchInlineSnapshot ( `
212
+ Object {
213
+ "name": "test123",
214
+ "origin": Object {
215
+ "database": "neondb",
216
+ "host": "example.com",
217
+ "password": "password",
218
+ "port": 3306,
219
+ "scheme": "mysql",
220
+ "user": "test",
221
+ },
222
+ }
223
+ ` ) ;
224
+ expect ( std . out ) . toMatchInlineSnapshot ( `
225
+ "🚧 Creating 'test123'
226
+ ✅ Created new Hyperdrive MySQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
192
227
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
193
228
194
229
{
@@ -227,7 +262,7 @@ describe("hyperdrive commands", () => {
227
262
` ) ;
228
263
expect ( std . out ) . toMatchInlineSnapshot ( `
229
264
"🚧 Creating 'test123'
230
- ✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
265
+ ✅ Created new Hyperdrive PostgreSQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
231
266
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
232
267
233
268
{
@@ -262,7 +297,7 @@ describe("hyperdrive commands", () => {
262
297
` ) ;
263
298
expect ( std . out ) . toMatchInlineSnapshot ( `
264
299
"🚧 Creating 'test123'
265
- ✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
300
+ ✅ Created new Hyperdrive PostgreSQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
266
301
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
267
302
268
303
{
@@ -297,7 +332,7 @@ describe("hyperdrive commands", () => {
297
332
` ) ;
298
333
expect ( std . out ) . toMatchInlineSnapshot ( `
299
334
"🚧 Creating 'test123'
300
- ✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
335
+ ✅ Created new Hyperdrive PostgreSQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
301
336
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
302
337
303
338
{
@@ -332,7 +367,7 @@ describe("hyperdrive commands", () => {
332
367
` ) ;
333
368
expect ( std . out ) . toMatchInlineSnapshot ( `
334
369
"🚧 Creating 'test123'
335
- ✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
370
+ ✅ Created new Hyperdrive PostgreSQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
336
371
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
337
372
338
373
{
@@ -367,7 +402,7 @@ describe("hyperdrive commands", () => {
367
402
` ) ;
368
403
expect ( std . out ) . toMatchInlineSnapshot ( `
369
404
"🚧 Creating 'test123'
370
- ✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
405
+ ✅ Created new Hyperdrive PostgreSQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
371
406
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
372
407
373
408
{
@@ -402,7 +437,42 @@ describe("hyperdrive commands", () => {
402
437
` ) ;
403
438
expect ( std . out ) . toMatchInlineSnapshot ( `
404
439
"🚧 Creating 'test123'
405
- ✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
440
+ ✅ Created new Hyperdrive PostgreSQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
441
+ 📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
442
+
443
+ {
444
+ \\"hyperdrive\\": [
445
+ {
446
+ \\"binding\\": \\"HYPERDRIVE\\",
447
+ \\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\"
448
+ }
449
+ ]
450
+ }"
451
+ ` ) ;
452
+ } ) ;
453
+
454
+ it ( "should create a hyperdrive config given individual params instead of a connection string" , async ( ) => {
455
+ const reqProm = mockHyperdriveCreate ( ) ;
456
+ await runWrangler (
457
+ "hyperdrive create test123 --host=example.com --database=neondb --user=test --password=password --port=1234 --origin-scheme=mysql"
458
+ ) ;
459
+
460
+ await expect ( reqProm ) . resolves . toMatchInlineSnapshot ( `
461
+ Object {
462
+ "name": "test123",
463
+ "origin": Object {
464
+ "database": "neondb",
465
+ "host": "example.com",
466
+ "password": "password",
467
+ "port": 1234,
468
+ "scheme": "mysql",
469
+ "user": "test",
470
+ },
471
+ }
472
+ ` ) ;
473
+ expect ( std . out ) . toMatchInlineSnapshot ( `
474
+ "🚧 Creating 'test123'
475
+ ✅ Created new Hyperdrive MySQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
406
476
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
407
477
408
478
{
@@ -429,6 +499,21 @@ describe("hyperdrive commands", () => {
429
499
` ) ;
430
500
} ) ;
431
501
502
+ it ( "should reject a create hyperdrive command if an unexpected origin-scheme is provided" , async ( ) => {
503
+ await expect ( ( ) =>
504
+ runWrangler (
505
+ "hyperdrive create test123 --host=example.com --port=5432 --database=foo --user=test --password=foo --origin-scheme=mongodb"
506
+ )
507
+ ) . rejects . toThrow ( ) ;
508
+ expect ( std . err ) . toMatchInlineSnapshot ( `
509
+ "[31mX [41;31m[[41;97mERROR[41;31m][0m [1mInvalid values:[0m
510
+
511
+ Argument: origin-scheme, Given: \\"mongodb\\", Choices: \\"postgres\\", \\"postgresql\\", \\"mysql\\"
512
+
513
+ "
514
+ ` ) ;
515
+ } ) ;
516
+
432
517
it ( "should reject a create hyperdrive command if both connection string and individual origin params are provided" , async ( ) => {
433
518
await expect ( ( ) =>
434
519
runWrangler (
@@ -463,7 +548,7 @@ describe("hyperdrive commands", () => {
463
548
` ) ;
464
549
expect ( std . out ) . toMatchInlineSnapshot ( `
465
550
"🚧 Creating 'test123'
466
- ✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
551
+ ✅ Created new Hyperdrive PostgreSQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
467
552
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
468
553
469
554
{
@@ -498,7 +583,7 @@ describe("hyperdrive commands", () => {
498
583
` ) ;
499
584
expect ( std . out ) . toMatchInlineSnapshot ( `
500
585
"🚧 Creating 'test123'
501
- ✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
586
+ ✅ Created new Hyperdrive PostgreSQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
502
587
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
503
588
504
589
{
@@ -564,7 +649,7 @@ describe("hyperdrive commands", () => {
564
649
` ) ;
565
650
expect ( std . out ) . toMatchInlineSnapshot ( `
566
651
"🚧 Creating 'test123'
567
- ✅ Created new Hyperdrive config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
652
+ ✅ Created new Hyperdrive PostgreSQL config: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
568
653
📋 To start using your config from a Worker, add the following binding configuration to your Wrangler configuration file:
569
654
570
655
{
@@ -583,15 +668,15 @@ describe("hyperdrive commands", () => {
583
668
await runWrangler ( "hyperdrive list" ) ;
584
669
expect ( std . out ) . toMatchInlineSnapshot ( `
585
670
"📋 Listing Hyperdrive configs
586
- ┌──────────────────────────────────────┬─────────────┬─────────┬────────────────┬──────┬───────────┬───────────────────┬───────────────────────────────────────────────────────────────┐
587
- │ id │ name │ user │ host │ port │ database │ caching │ mtls │
588
- ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼───────────┼───────────────────┼───────────────────────────────────────────────────────────────┤
589
- │ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx │ test123 │ test │ example.com │ 5432 │ neondb │ │ │
590
- ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼───────────┼───────────────────┼───────────────────────────────────────────────────────────────┤
591
- │ yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy │ new-db │ dbuser │ www.google.com │ 3211 │ mydb │ {\\"disabled\\":true} │ │
592
- ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼───────────┼───────────────────┼───────────────────────────────────────────────────────────────┤
593
- │ zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz │ new-db-mtls │ pg-mtls │ www.mtls.com │ 3212 │ mydb-mtls │ │ {\\"ca_certificate_uuid\\":\\"1234\\",\\"mtls_certificate_uuid\\":\\"1234\\"} │
594
- └──────────────────────────────────────┴─────────────┴─────────┴────────────────┴──────┴───────────┴───────────────────┴───────────────────────────────────────────────────────────────┘"
671
+ ┌──────────────────────────────────────┬─────────────┬─────────┬────────────────┬──────┬────────────┬─────────── ┬───────────────────┬───────────────────────────────────────────────────────────────┐
672
+ │ id │ name │ user │ host │ port │ scheme │ database │ caching │ mtls │
673
+ ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼────────────┼─────────── ┼───────────────────┼───────────────────────────────────────────────────────────────┤
674
+ │ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx │ test123 │ test │ example.com │ 5432 │ PostgreSQL │ neondb │ │ │
675
+ ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼────────────┼─────────── ┼───────────────────┼───────────────────────────────────────────────────────────────┤
676
+ │ yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy │ new-db │ dbuser │ www.google.com │ 3211 │ PostgreSQL │ mydb │ {\\"disabled\\":true} │ │
677
+ ├──────────────────────────────────────┼─────────────┼─────────┼────────────────┼──────┼────────────┼─────────── ┼───────────────────┼───────────────────────────────────────────────────────────────┤
678
+ │ zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz │ new-db-mtls │ pg-mtls │ www.mtls.com │ 3212 │ │ mydb-mtls │ │ {\\"ca_certificate_uuid\\":\\"1234\\",\\"mtls_certificate_uuid\\":\\"1234\\"} │
679
+ └──────────────────────────────────────┴─────────────┴─────────┴────────────────┴──────┴────────────┴─────────── ┴───────────────────┴───────────────────────────────────────────────────────────────┘"
595
680
` ) ;
596
681
} ) ;
597
682
0 commit comments