Testing Strategy
Relevant source files
The following files were used as context for generating this wiki page:
The Daco CLI project employs a rigorous testing strategy centered on automated validation of schema parsing, transformation, and configuration management. The project prioritizes reliability through comprehensive unit testing, race detection, and cross-platform verification to ensure the integrity of data product specifications.
The testing architecture focuses on three primary pillars: specification parsing (OpenDPI), schema traversal/loading (JSON Schema), and code generation (Translators). By utilizing a mix of table-driven tests and Golden File-style output assertions, the project ensures that complex schema relationships and translation logic remain stable across iterations.
Sources: CONTRIBUTING.md:120-131, internal/opendpi/parse_test.go:12-20
Core Testing Methodologies
The project follows several key design principles and technical workflows to maintain high code quality and test coverage.
Continuous Integration and Automation
The CI/CD pipeline, executed on every push to main and on all pull requests, includes three critical stages:
- Linting: Utilizing
golangci-lintwith specific project configurations. - Testing: Execution of
go test -v -race ./...to detect logic errors and data races. - Build Verification: Cross-platform build checks for Linux, Darwin, and Windows.
Sources: CONTRIBUTING.md:162-171, CONTRIBUTING.md:197-206
Table-Driven Testing
Most test suites, particularly in internal/opendpi and internal/translate, utilize table-driven tests to validate multiple scenarios (e.g., YAML vs. JSON input) using a shared execution block.
The diagram above illustrates the standard flow of table-driven tests used throughout the repository to ensure consistent validation across different file formats.
Sources: internal/opendpi/parse_test.go:12-40, internal/config/config_test.go:37-60
Domain-Specific Testing
OpenDPI Specification Parsing
Testing for OpenDPI parsing focuses on the resolution of connections, port definitions, and schema references. Tests verify that external schema files (YAML/JSON) are correctly loaded and that internal $ref pointers are resolved into a final Spec object.
| Feature Tested | Description | File Source |
|---|---|---|
| Connection Resolution | Verifies that port connections correctly reference items in the Connections map. | internal/opendpi/parse_test.go:35-42 |
| Cross-Format Refs | Ensures YAML specs can reference JSON schemas and vice versa. | internal/opendpi/parse_test.go:394-444 |
| Circular References | Validates that the parser does not hang or panic when encountering self-referential schemas. | internal/opendpi/parse_test.go:343-368 |
| Spec Writing | Confirms that Spec objects can be converted back to raw formats without losing data. | internal/opendpi/writer_test.go:193-270 |
Sources: internal/opendpi/parse_test.go:12-58, internal/opendpi/writer_test.go:275-310
Schema Translation and Generation
The translate packages (Python, Go, Scala, Protobuf, etc.) are tested by asserting that the Translate function produces specific code snippets and maintains topological order for dependencies.
This sequence ensures that dependent types (e.g., an Address struct used by a User struct) are generated in the correct order to satisfy language-specific requirements.
Sources: internal/translate/python/translator_test.go:167-198, internal/translate/gotypes/translator_test.go:137-172
JSON Schema Loader and Traversal
Tests for jschema verify the low-level mechanics of navigating complex schemas.
- Loader Tests: Verify file system abstraction (
os.DirFS) and the resolution of relative paths in$ref. - Traversal Tests: Ensure every node in a schema (including
allOf,anyOf, andconditionalkeywords) is visited exactly once.
Sources: internal/jschema/loader_test.go:12-40, internal/jschema/traverse_test.go:21-45
Tools and Configuration
The project specifies exact tool versions and configurations to ensure testing consistency across developer environments.
| Tool | Purpose | Version |
|---|---|---|
| Go | Primary runtime and test runner | 1.23.0+ |
| golangci-lint | Static analysis and code quality | latest |
| testify | Assertion framework for unit tests | (latest) |
| Make | Automation of test execution commands | any |
Testing is facilitated via the following Makefile targets:
make test: Runs all tests with race detection.make lint: Executes the linter.make format: Formats code usinggofmtandgoimports.
Sources: CONTRIBUTING.md:41-47, CONTRIBUTING.md:213-228
Summary
Daco CLI's testing strategy relies on high-fidelity simulation of schema parsing and code generation. By combining table-driven unit tests with comprehensive CI/CD checks and race detection, the project maintains a stable foundation for transforming complex data product specifications into multi-language code artifacts. Caching and resolution of external file references are central to the testing of the jschema and opendpi modules, ensuring that real-world, multi-file specifications are handled reliably.