Skip to content

Add baseline unit coverage for schema parsing and YAML generation#10

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/add-test-coverage
Draft

Add baseline unit coverage for schema parsing and YAML generation#10
Copilot wants to merge 2 commits into
mainfrom
copilot/add-test-coverage

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 17, 2026

The codebase had no tests around its highest-risk logic: OpenAPI schema resolution/parsing and YAML scaffold generation. This adds targeted unit coverage for those paths without changing runtime behavior.

  • Schema parsing coverage

    • Adds unit tests in src/schema.rs for definition-key selection across matching strategies.
    • Covers v2 parsing with nested $ref resolution, required-field propagation, enums/defaults, arrays, and additionalProperties maps.
    • Covers v3 parsing through the existing Ctx flow to verify nested object expansion and map value typing.
  • YAML generation coverage

    • Adds unit tests in src/generate.rs for filter_fields behavior in --minimal, default, and fallback cases.
    • Verifies the is_commonly_needed heuristic against representative included/excluded fields.
    • Exercises the YamlNode emitter for nested objects, arrays, inline comments, and free-form map placeholders.
  • Approach

    • Keeps coverage close to the implementation with #[cfg(test)] modules in the two core files.
    • Uses small in-memory fixtures to lock down behavior without introducing new test infrastructure.
#[test]
fn filter_fields_default_keeps_commonly_needed_fields() {
    let fields = vec![test_field("image", false), test_field("debug", false)];

    let filtered = filter_fields(&fields, false, false);

    assert_eq!(filtered.len(), 1);
    assert_eq!(filtered[0].name, "image");
}

Copilot AI linked an issue Apr 17, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Add test coverage for codebase modules Add baseline unit coverage for schema parsing and YAML generation Apr 17, 2026
Copilot AI requested a review from rawkode April 17, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add test coverage (currently 0%)

2 participants