Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log error when invalid contract paths are selected by user #1140

Merged
merged 2 commits into from
Jul 11, 2024

Conversation

yogeshnikam671
Copy link
Member

@yogeshnikam671 yogeshnikam671 commented Jun 9, 2024

What:
If we run the test against a folder (i.e. not a valid contract file path),
we get following log messages -

Endpoints API not found, cannot calculate actual coverage

Could not load report configuration, coverage will be calculated but no coverage threshold will be enforced
The Open API coverage report generated is blank.
This can happen if you have included all the endpoints in the 'excludedEndpoints' array in the report section in specmatic.json, or if your open api specification does not have any paths documented.

It does not mention that it is failing because a file with valid extension was not selected.

With this change, we will get additional error message as follows -

Endpoints API not found, cannot calculate actual coverage

Could not load report configuration, coverage will be calculated but no coverage threshold will be enforced
The Open API coverage report generated is blank.
This can happen if you have included all the endpoints in the 'excludedEndpoints' array in the report section in specmatic.json, or if your open api specification does not have any paths documented.

No valid specification file found at given paths : /Users/yogeshanandanikam/personal_projects/specmatic-intellij-plugin

Why:
Better user experience.

How:
Logs a message when the contract paths are not empty but none of them is valid.

Checklist:

Copy link
Member

@harikrishnan83 harikrishnan83 left a comment

Choose a reason for hiding this comment

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

Should we do this for stub?

@yogeshnikam671 yogeshnikam671 force-pushed the log_error_when_invalid_contract_path branch from 61358c2 to 1dfe8ec Compare July 10, 2024 05:01
Copy link
Member

@joelrosario joelrosario left a comment

Choose a reason for hiding this comment

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

Hi @yogeshnikam671, thanks, the logic looks good. I've requested a few changes with respect to removing duplication and the format of the error message.

core/src/main/kotlin/in/specmatic/stub/api.kt Outdated Show resolved Hide resolved
core/src/main/kotlin/in/specmatic/stub/api.kt Outdated Show resolved Hide resolved
Copy link
Member

@joelrosario joelrosario left a comment

Choose a reason for hiding this comment

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

LGTM

@joelrosario joelrosario merged commit 1c0931b into main Jul 11, 2024
2 checks passed
@joelrosario joelrosario deleted the log_error_when_invalid_contract_path branch July 11, 2024 04:23
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.

None yet

3 participants