This directory contains PowerShell scripts for running comprehensive tests of the ptah core renderer, including the newly implemented visitor methods for DropIndex, CreateType, and AlterType.
- Docker Desktop - Required for running database integration tests
- Go 1.26.5+ - For running the tests. This is the
godirective ingo.mod, the published compatibility floor — not the patch release CI builds with, which is thetoolchaindirective. - PowerShell 7+ - For running the test scripts (works on Windows, macOS, Linux)
# Run all tests (recommended)
.\test-all.ps1
# Run only the new visitor methods tests
.\test-new-methods.ps1
# Run unit tests only (no databases needed)
.\test-all.ps1 -Category unit| Script | Purpose | Database Required |
|---|---|---|
test-all.ps1 |
Comprehensive test runner with multiple options | Conditional |
test-new-methods.ps1 |
Quick test for new visitor methods | Yes |
run-integration-tests.ps1 |
Full integration test runner | Yes |
The main test script with multiple categories and options:
# Run all tests
.\test-all.ps1
# Run only unit tests (fast, no databases)
.\test-all.ps1 -Category unit
# Run integration tests for specific dialect
.\test-all.ps1 -Category integration -Dialect postgresql
# Run essential tests only (faster)
.\test-all.ps1 -Quick
# Test specific dialect
.\test-all.ps1 -Dialect mysqlCategories:
unit- Unit tests only (AST, renderer logic)integration- Integration tests with real databasesnew-methods- Tests for DropIndex, CreateType, AlterTypeall- All test categories (default)
Dialects:
postgresql- PostgreSQL tests onlymysql- MySQL tests onlymariadb- MariaDB tests onlyall- All dialects (default)
Quick test script focusing on the newly implemented visitor methods:
# Test new methods
.\test-new-methods.ps1
# Test and keep databases running for debugging
.\test-new-methods.ps1 -KeepDatabasesTests the following functionality:
VisitDropIndex- DROP INDEX statementsVisitCreateType- CREATE TYPE statements (enums, domains, composite types)VisitAlterType- ALTER TYPE statements (add values, rename, etc.)
Detailed integration test runner with Docker Compose:
# Run all integration tests
.\run-integration-tests.ps1
# Run specific test pattern
.\run-integration-tests.ps1 -TestPattern "TestDropIndex"
# Verbose output and keep databases
.\run-integration-tests.ps1 -Verbose -KeepDatabases
# Skip Docker image building
.\run-integration-tests.ps1 -SkipBuildThe integration tests use Docker Compose to start:
- PostgreSQL 18 on port 5432
- MySQL 26.7 on port 3310
- MariaDB 12.3 on port 3307
Connection details:
- Database:
ptah_test - Username:
ptah_user - Password:
ptah_password
✅ DropIndex Tests:
- PostgreSQL:
DROP INDEX [IF EXISTS] name; - MySQL/MariaDB:
DROP INDEX name ON table;
✅ CreateType Tests:
- PostgreSQL: Full support for ENUM, DOMAIN, COMPOSITE types
- MySQL/MariaDB: Informative comments (types handled inline)
✅ AlterType Tests:
- PostgreSQL: ADD VALUE, RENAME VALUE, RENAME TYPE operations
- MySQL/MariaDB: Informative comments (use ALTER TABLE instead)
-
Unit Tests - No database required
- AST node functionality
- Renderer interface compliance
- SQL generation logic
-
Integration Tests - Real database connections
- Actual SQL execution
- Database-specific syntax validation
- Cross-dialect compatibility
-
Dialect-Specific Tests
- PostgreSQL advanced features
- MySQL/MariaDB compatibility
- Error handling and edge cases
# Check Docker status
docker --version
docker compose --version
# View database logs
docker compose logs postgres mysql mariadb
# Clean up containers
docker compose down -v# Run with verbose output
.\run-integration-tests.ps1 -Verbose
# Keep databases for debugging
.\run-integration-tests.ps1 -KeepDatabases
# Test specific pattern
.\run-integration-tests.ps1 -TestPattern "TestDropIndex"# Quick tests only
.\test-all.ps1 -Quick
# Unit tests only (fastest)
.\test-all.ps1 -Category unit
# Specific dialect only
.\test-all.ps1 -Dialect postgresql# 1. Quick unit tests during development
.\test-all.ps1 -Category unit
# 2. Test new functionality
.\test-new-methods.ps1
# 3. Full integration test before commit
.\test-all.ps1
# 4. Test specific database if issues found
.\test-all.ps1 -Dialect mysql -Verbose# Comprehensive test suite for CI
.\test-all.ps1 -Category all -Verbose
# Quick smoke test
.\test-all.ps1 -Quick0- All tests passed1- Test failures or errors2- Script parameter errors3- Docker/environment issues
All scripts return appropriate exit codes for CI/CD integration.
Ptah enforces the current declarative-test and white-box-test baseline while issue #541 is being cleaned up:
scripts/check-test-style.shThe check fails when a PR adds a new prohibited conditional in a top-level
Test*, Fuzz*, or Example* function, adds a same-package test file that is
not named *_internal_test.go, or adds an internal test file without an
// White-box testing required: justification comment as the first non-empty
line after the package clause.
Cleanup PRs should reduce .teststyle-baseline.json with:
scripts/check-test-style.sh --write-baselineThe script scans the files git reports for this checkout rather than walking the
filesystem, so both the check and the regeneration ignore linked git worktrees
parked under the repository. go tool teststyle -write-baseline run directly
does walk them, and records their tests into the tracked baseline.
scripts/check-test-style.sh --list-scan-paths prints the exact set of files the
gate will judge, which is the quickest way to confirm a file is in scope.