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
@@ -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.
203
+
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
204
313
205
### Test Timeouts
314
206
@@ -326,19 +218,23 @@ go test -race ./...
326
218
327
219
### Database Connection Failures
328
220
329
-
Ensure Docker containers are running:
221
+
If using Docker:
330
222
```bash
331
223
docker compose ps
332
224
docker compose up -d
333
225
```
334
226
227
+
If using sqlc-test-setup:
228
+
```bash
229
+
go run ./cmd/sqlc-test-setup start
230
+
```
231
+
335
232
## Tips for Contributors
336
233
337
-
1.**Run tests before committing:**`make test-ci`
234
+
1.**Run tests before committing:**`go test --tags=examples -timeout 20m ./...`
338
235
2.**Check for race conditions:** Use `-race` flag when testing concurrent code
339
236
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`
237
+
4.**Read existing tests:** Good examples in `/internal/engine/postgresql/*_test.go`
342
238
343
239
## Git Workflow
344
240
@@ -350,34 +246,18 @@ docker compose up -d
350
246
### Committing Changes
351
247
352
248
```bash
353
-
# Stage changes
354
249
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