Commit d810d21
Fix db test-connection command to work with keyring password storage
- Add buildConnectionConfig() function to handle pgx config with password retrieval
- Refactor testDatabaseConnection() to use buildConnectionConfig() for better testability
- Set config.Password when using keyring storage method for pgx authentication
- Preserve existing pgpass behavior (pgx automatically checks ~/.pgpass file)
- Update function signatures to pass service parameter for password retrieval
- Add comprehensive tests that verify password is actually set in pgx config:
- TestBuildConnectionConfig_KeyringPassword: Stores real password in keyring and verifies config.Password is set
- TestBuildConnectionConfig_PgpassStorage_NoPasswordSet: Verifies no password set for pgpass method
- Update existing tests with service parameter for compatibility
- Follow same pattern as db psql fix for consistency
The db test-connection command now works properly with all password storage methods:
- keyring: Retrieves password from keyring and sets config.Password for pgx
- pgpass: Lets pgx automatically read ~/.pgpass file (unchanged)
- none: Uses interactive prompts or existing environment variables (unchanged)
Tests actually verify that password retrieval and config setting works correctly.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent bba9797 commit d810d21
2 files changed
+110
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
194 | 194 | | |
195 | 195 | | |
196 | 196 | | |
197 | | - | |
| 197 | + | |
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
| |||
382 | 382 | | |
383 | 383 | | |
384 | 384 | | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
385 | 407 | | |
386 | | - | |
| 408 | + | |
387 | 409 | | |
388 | 410 | | |
389 | 411 | | |
| |||
395 | 417 | | |
396 | 418 | | |
397 | 419 | | |
398 | | - | |
399 | | - | |
| 420 | + | |
| 421 | + | |
400 | 422 | | |
401 | | - | |
| 423 | + | |
402 | 424 | | |
403 | 425 | | |
404 | 426 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
417 | 417 | | |
418 | 418 | | |
419 | 419 | | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
420 | 499 | | |
421 | 500 | | |
422 | 501 | | |
| |||
582 | 661 | | |
583 | 662 | | |
584 | 663 | | |
585 | | - | |
| 664 | + | |
| 665 | + | |
586 | 666 | | |
587 | 667 | | |
588 | 668 | | |
| |||
610 | 690 | | |
611 | 691 | | |
612 | 692 | | |
| 693 | + | |
613 | 694 | | |
614 | | - | |
| 695 | + | |
615 | 696 | | |
616 | 697 | | |
617 | 698 | | |
| |||
0 commit comments