Skip to content

feat: add --schema-name option to test command#1085

Open
kelsoufi-sanofi wants to merge 4 commits intodatacontract:mainfrom
kelsoufi-sanofi:feat/add-schema-name-to-test-command
Open

feat: add --schema-name option to test command#1085
kelsoufi-sanofi wants to merge 4 commits intodatacontract:mainfrom
kelsoufi-sanofi:feat/add-schema-name-to-test-command

Conversation

@kelsoufi-sanofi
Copy link
Copy Markdown

@kelsoufi-sanofi kelsoufi-sanofi commented Mar 19, 2026

Closes #1079

Summary

  • Adds a --schema-name option to the test command, allowing users to test a specific schema (e.g., --schema-name orders) instead of all schemas
  • Defaults to "all", preserving existing behavior
  • Includes unit tests for schema filtering and a CLI help test

Test plan

  • All existing tests pass (pytest)
  • New tests cover: filtering by name, default behavior, non-existent schema
  • CLI help shows --schema-name option
  • ruff format and ruff check pass clean

kelsoufi-sanofi and others added 2 commits March 19, 2026 14:06
Add --schema-name flag to `datacontract test` to filter which schema
object to test, consistent with the existing --schema-name on `export`.

Defaults to "all" (existing behavior). When a specific schema name is
provided, only checks for that schema are generated and executed.

Closes datacontract#1079

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@kelsoufi-sanofi
Copy link
Copy Markdown
Author

@jochenchrist should be good now. let me know. thanks

Copy link
Copy Markdown
Contributor

@jochenchrist jochenchrist left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

# TODO check server is supported type for nicer error messages
# TODO check server credentials are complete for nicer error messages
if server.format == "json" and server.type != "kafka":
check_jsonschema(run, data_contract, server)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But this will still run for all schemas, or did I overlook something?


def test_test_schema_name_option_in_help():
"""Test that --schema-name option is available in test command help."""
result = runner.invoke(app, ["test", "--help"])
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result = runner.invoke(app, ["test", "--help"])
result = runner.invoke(app, ["test", "--help"], env={"COLUMNS": "200"})

Seems like the test output gets truncated in the CI test, making --schema-name not fully appear there. Increasing the terminal width for this specific test could help.

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.

[Feature Request] Add --schema-name to test to filter

3 participants