Skip to content

Add sqlc-test-setup command for database test environment setup#4304

Open
kyleconroy wants to merge 4 commits intomainfrom
claude/sqlc-test-setup-package-MitRq
Open

Add sqlc-test-setup command for database test environment setup#4304
kyleconroy wants to merge 4 commits intomainfrom
claude/sqlc-test-setup-package-MitRq

Conversation

@kyleconroy
Copy link
Collaborator

New cmd/sqlc-test-setup package with two subcommands:

  • install: Installs PostgreSQL and MySQL 9 via apt, including apt
    proxy configuration for Claude Code remote environments.
  • start: Starts both database services, configures authentication
    (passwords, pg_hba.conf), and verifies connectivity.

Both commands log all actions verbosely for easy debugging.

https://claude.ai/code/session_01CsyRwSkRxBcQoaQFVkMQsJ

New cmd/sqlc-test-setup package with two subcommands:
- `install`: Installs PostgreSQL and MySQL 9 via apt, including apt
  proxy configuration for Claude Code remote environments.
- `start`: Starts both database services, configures authentication
  (passwords, pg_hba.conf), and verifies connectivity.

Both commands log all actions verbosely for easy debugging.

https://claude.ai/code/session_01CsyRwSkRxBcQoaQFVkMQsJ
Key fixes:
- Use apt-get install -f to resolve dpkg dependency issues (libaio1t64,
  libmecab2, libnuma1) instead of expecting all dpkg -i to succeed
- Remove /etc/init.d/mysql chmod (not present in systemd environments)
- Use mysqld_safe to start MySQL (works without systemd/init.d)
- Use caching_sha2_password plugin instead of auth_socket for TCP access
- Add waitForMySQL polling loop for reliable startup detection

Idempotency:
- install: Skips apt proxy, PostgreSQL, and MySQL if already present
- start: Detects running MySQL via mysqladmin ping, skips pg_hba.conf
  entry if already configured, skips password setup if already correct,
  skips MySQL data dir initialization if already done

Tested: both commands succeed on first run and on subsequent re-runs.

https://claude.ai/code/session_01CsyRwSkRxBcQoaQFVkMQsJ
…UDE.md

- docker.Installed(): Also verify Docker daemon is running (not just
  binary in PATH). Without this, tests try Docker first, fail on
  docker pull, and t.Fatal instead of falling back to native databases.

- expander_test.go: Use the same Docker/native detection chain as other
  tests instead of hardcoding connection URIs. The PostgreSQL test was
  hardcoded to password 'mysecretpassword' which doesn't match native
  setup (password 'postgres').

- CLAUDE.md: Replace manual apt/dpkg database setup instructions with
  sqlc-test-setup commands. Remove Step 1-4 manual instructions.

All 29 test packages pass with zero skips.

https://claude.ai/code/session_01CsyRwSkRxBcQoaQFVkMQsJ
Adds database setup before the test step so integration tests
can connect to PostgreSQL and MySQL without Docker.

https://claude.ai/code/session_01CsyRwSkRxBcQoaQFVkMQsJ
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. 🔧 golang labels Feb 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XL This PR changes 500-999 lines, ignoring generated files. 🔧 golang

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments