Unit
Unit
The unit command runs unit tests on Trilogy scripts with mocked datasources. It always uses DuckDB internally.
Usage
trilogy unit <input> [options]
Arguments
| Argument | Description |
|---|---|
input | Path to a Trilogy script or directory. |
Options
| Option | Description |
|---|---|
--param key=value | Environment parameters. Repeatable. |
-p, --parallelism INTEGER | Maximum parallel workers for directory execution. |
--config PATH | Path to a trilogy.toml configuration file. |
-e, --env TEXT | Set env vars as KEY=VALUE, or pass an env file path. |
Full Examples
# Test single file
trilogy unit test_query.preql
# Test entire directory
trilogy unit tests/ -p 4
# Test with parameters
trilogy unit script.preql --param batch_size=100
# Test with config file
trilogy unit . --config trilogy.toml
What It Does
- Parses the script(s)
- Validates datasources with mocked data (no real database connection needed)
- Reports validation results and any errors
Notes
- No dialect argument needed - always uses DuckDB
- No connection arguments needed - all datasources are mocked
- Fast feedback loop for development and CI/CD
- Validates business logic and syntax without requiring database access