You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix test infrastructure: Docker detection, expander tests, update CLAUDE.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
@@ -10,136 +10,74 @@ This document provides essential information for working with the sqlc codebase,
10
10
-**Docker & Docker Compose** - Required for integration tests with databases (local development)
11
11
-**Git** - For version control
12
12
13
-
## Claude Code Remote Environment Setup
13
+
## Database Setup with sqlc-test-setup
14
14
15
-
When running in the Claude Code remote environment (or any environment without Docker), you can install PostgreSQL and MySQL natively. The test framework automatically detects and uses native database installations.
15
+
The `sqlc-test-setup` tool (`cmd/sqlc-test-setup/`) automates installing and starting PostgreSQL and MySQL for tests. Both commands are idempotent and safe to re-run.
16
16
17
-
### Step 1: Configure apt Proxy (Required in Remote Environment)
18
-
19
-
The Claude Code remote environment requires an HTTP proxy for apt. Configure it:
20
-
21
-
```bash
22
-
bash -c 'echo "Acquire::http::Proxy \"$http_proxy\";"'| sudo tee /etc/apt/apt.conf.d/99proxy
23
-
```
24
-
25
-
### Step 2: Install PostgreSQL
17
+
### Install databases
26
18
27
19
```bash
28
-
sudo apt-get update
29
-
sudo apt-get install -y postgresql
30
-
sudo service postgresql start
20
+
go run ./cmd/sqlc-test-setup install
31
21
```
32
22
33
-
Configure PostgreSQL for password authentication:
34
-
35
-
```bash
36
-
# Set password for postgres user
37
-
sudo -u postgres psql -c "ALTER USER postgres PASSWORD 'postgres';"
38
-
39
-
# Enable password authentication for localhost
40
-
echo'host all all 127.0.0.1/32 md5'| sudo tee -a /etc/postgresql/16/main/pg_hba.conf
41
-
sudo service postgresql reload
42
-
```
23
+
This will:
24
+
- Configure the apt proxy (if `http_proxy` is set, e.g. in Claude Code remote environments)
25
+
- Install PostgreSQL via apt
26
+
- Download and install MySQL 9 from Oracle's deb bundle
If you see errors about `storage.googleapis.com`, the Go proxy may be unreachable. Tests may still pass for packages that don't require network dependencies.
202
+
If you see errors about `storage.googleapis.com`, the Go proxy may be unreachable. Use `GOPROXY=direct go mod download` to fetch modules directly from source.
312
203
313
204
### Test Timeouts
314
205
@@ -326,19 +217,23 @@ go test -race ./...
326
217
327
218
### Database Connection Failures
328
219
329
-
Ensure Docker containers are running:
220
+
If using Docker:
330
221
```bash
331
222
docker compose ps
332
223
docker compose up -d
333
224
```
334
225
226
+
If using sqlc-test-setup:
227
+
```bash
228
+
go run ./cmd/sqlc-test-setup start
229
+
```
230
+
335
231
## Tips for Contributors
336
232
337
-
1.**Run tests before committing:**`make test-ci`
233
+
1.**Run tests before committing:**`go test --tags=examples -timeout 20m ./...`
338
234
2.**Check for race conditions:** Use `-race` flag when testing concurrent code
339
235
3.**Use specific package tests:** Faster iteration during development
340
-
4.**Start databases early:**`docker compose up -d` before running integration tests
341
-
5.**Read existing tests:** Good examples in `/internal/engine/postgresql/*_test.go`
236
+
4.**Read existing tests:** Good examples in `/internal/engine/postgresql/*_test.go`
342
237
343
238
## Git Workflow
344
239
@@ -350,34 +245,18 @@ docker compose up -d
350
245
### Committing Changes
351
246
352
247
```bash
353
-
# Stage changes
354
248
git add <files>
355
-
356
-
# Commit with descriptive message
357
-
git commit -m "Brief description
358
-
359
-
Detailed explanation of changes.
360
-
361
-
🤖 Generated with [Claude Code](https://claude.com/claude-code)
0 commit comments