Unit
Unit
The unit command runs unit tests on Trilogy scripts with mocked datasources. It always uses DuckDB internally.
Arguments:
@argument("input", type=Path())
@option("--param", multiple=True, help="Environment parameters as key=value pairs")
@option("--parallelism", "-p", default=None, help="Maximum parallel workers for directory execution")
@option("--config", type=Path(exists=True), help="Path to trilogy.toml configuration file")
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
