@@ -178,6 +178,78 @@ describe("hyperdrive commands", () => {
178
178
` ) ;
179
179
} ) ;
180
180
181
+ it ( "should handle creating a hyperdrive config if the user is URL encoded" , async ( ) => {
182
+ mockHyperdriveRequest ( ) ;
183
+ await runWrangler (
184
+ "hyperdrive create test123 --connection-string='postgresql://user%3Aname:password@example.com/neondb'"
185
+ ) ;
186
+ expect ( std . out ) . toMatchInlineSnapshot ( `
187
+ "🚧 Creating 'test123'
188
+ ✅ Created new Hyperdrive config
189
+ {
190
+ \\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\",
191
+ \\"name\\": \\"test123\\",
192
+ \\"origin\\": {
193
+ \\"host\\": \\"example.com\\",
194
+ \\"port\\": 5432,
195
+ \\"database\\": \\"neondb\\",
196
+ \\"user\\": \\"user:name\\"
197
+ },
198
+ \\"caching\\": {
199
+ \\"disabled\\": false
200
+ }
201
+ }"
202
+ ` ) ;
203
+ } ) ;
204
+
205
+ it ( "should handle creating a hyperdrive config if the password is URL encoded" , async ( ) => {
206
+ mockHyperdriveRequest ( ) ;
207
+ await runWrangler (
208
+ "hyperdrive create test123 --connection-string='postgresql://test:a%23%3F81n%287@example.com/neondb'"
209
+ ) ;
210
+ expect ( std . out ) . toMatchInlineSnapshot ( `
211
+ "🚧 Creating 'test123'
212
+ ✅ Created new Hyperdrive config
213
+ {
214
+ \\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\",
215
+ \\"name\\": \\"test123\\",
216
+ \\"origin\\": {
217
+ \\"host\\": \\"example.com\\",
218
+ \\"port\\": 5432,
219
+ \\"database\\": \\"neondb\\",
220
+ \\"user\\": \\"test\\"
221
+ },
222
+ \\"caching\\": {
223
+ \\"disabled\\": false
224
+ }
225
+ }"
226
+ ` ) ;
227
+ } ) ;
228
+
229
+ it ( "should handle creating a hyperdrive config if the database name is URL encoded" , async ( ) => {
230
+ mockHyperdriveRequest ( ) ;
231
+ await runWrangler (
232
+ "hyperdrive create test123 --connection-string='postgresql://test:password@example.com/%22weird%22%20dbname'"
233
+ ) ;
234
+ expect ( std . out ) . toMatchInlineSnapshot ( `
235
+ "🚧 Creating 'test123'
236
+ ✅ Created new Hyperdrive config
237
+ {
238
+ \\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\",
239
+ \\"name\\": \\"test123\\",
240
+ \\"origin\\": {
241
+ \\"host\\": \\"example.com\\",
242
+ \\"port\\": 5432,
243
+ \\"database\\": \\"/\\"weird/\\" dbname\\",
244
+ \\"user\\": \\"test\\"
245
+ },
246
+ \\"caching\\": {
247
+ \\"disabled\\": false
248
+ }
249
+ }"
250
+ ` ) ;
251
+ } ) ;
252
+
181
253
it ( "should handle listing configs" , async ( ) => {
182
254
mockHyperdriveRequest ( ) ;
183
255
await runWrangler ( "hyperdrive list" ) ;
@@ -258,10 +330,7 @@ describe("hyperdrive commands", () => {
258
330
259
331
"
260
332
` ) ;
261
- expect ( std . out ) . toMatchInlineSnapshot ( `
262
- "
263
- [32mIf you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose[0m"
264
- ` ) ;
333
+ expect ( std . out ) . toMatchInlineSnapshot ( `""` ) ;
265
334
} ) ;
266
335
267
336
it ( "should handle updating a hyperdrive config's caching settings" , async ( ) => {
@@ -290,6 +359,30 @@ describe("hyperdrive commands", () => {
290
359
` ) ;
291
360
} ) ;
292
361
362
+ it ( "should handle disabling caching for a hyperdrive config" , async ( ) => {
363
+ mockHyperdriveRequest ( ) ;
364
+ await runWrangler (
365
+ "hyperdrive update xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx --caching-disabled=true"
366
+ ) ;
367
+ expect ( std . out ) . toMatchInlineSnapshot ( `
368
+ "🚧 Updating 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
369
+ ✅ Updated xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx Hyperdrive config
370
+ {
371
+ \\"id\\": \\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\\",
372
+ \\"name\\": \\"test123\\",
373
+ \\"origin\\": {
374
+ \\"host\\": \\"example.com\\",
375
+ \\"port\\": 5432,
376
+ \\"database\\": \\"neondb\\",
377
+ \\"user\\": \\"test\\"
378
+ },
379
+ \\"caching\\": {
380
+ \\"disabled\\": true
381
+ }
382
+ }"
383
+ ` ) ;
384
+ } ) ;
385
+
293
386
it ( "should handle updating a hyperdrive config's name" , async ( ) => {
294
387
mockHyperdriveRequest ( ) ;
295
388
await runWrangler (
0 commit comments