mirror of
https://github.com/bahdotsh/wrkflw.git
synced 2026-09-02 12:16:16 +02:00
The PR review flagged three issues worth fixing before merge. First, run_step_with_guards had a bogus StepStatus::Skipped check in the abort_job logic. The condition tested for Failure *or* Skipped, then only actually aborted on Failure — meaning the Skipped branch did nothing except confuse anyone reading the code. Simplify to just check Failure directly. Second, EncryptedSecretStore::from_json would silently fail with a generic serde error when fed the old serialization format (which had a shared top-level nonce field). Now it detects the old format by checking for the "nonce" key and returns a clear error pointing at BREAKING_CHANGES.md. Added a test for this. Third, tests/workflows/continue-on-error-test.yml was an orphan fixture — nothing referenced it. The same content is already tested inline by parse_continue_on_error_workflow in the parser. Removed it.
Testing Strategy
This directory contains all tests and test-related files for the wrkflw project. We follow the Rust testing best practices by organizing tests as follows:
Test Organization
- Unit Tests: Located alongside the source files in
src/using#[cfg(test)]modules - Integration Tests: Located directly in this
tests/directorymatrix_test.rs- Tests for matrix expansion functionalityreusable_workflow_test.rs- Tests for reusable workflow validation
- End-to-End Tests: Also located in this
tests/directorycleanup_test.rs- Tests for cleanup functionality with Docker resources
Test Directory Structure
fixtures/: Test data and configuration filesgitlab-ci/- GitLab CI configuration files for testing
workflows/: GitHub Actions workflow files for testing- Various YAML files for testing workflow validation and execution
scripts/: Test automation scriptstest-podman-basic.sh- Basic Podman integration test scripttest-preserve-containers.sh- Container preservation testing script
TESTING_PODMAN.md: Comprehensive Podman testing documentation
Running Tests
To run all tests:
cargo test
To run only unit tests:
cargo test --lib
To run only integration tests:
cargo test --test matrix_test --test reusable_workflow_test
To run only end-to-end tests:
cargo test --test cleanup_test
To run a specific test:
cargo test test_name
Writing Tests
Please follow these guidelines when writing tests:
- Use meaningful test names that describe what is being tested
- Group related tests together in modules
- Use helper functions to reduce duplication
- Test both success and failure cases
- Use
#[should_panic]for tests that expect a panic - Avoid test interdependencies