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

Implements unified result structure #221

Merged
merged 29 commits into from Jul 12, 2019
Merged

Implements unified result structure #221

merged 29 commits into from Jul 12, 2019

Conversation

artem-zakharchenko
Copy link
Contributor

@artem-zakharchenko artem-zakharchenko commented Jun 26, 2019

Contains implementation of the unified result structure and internals re-design for Gavel. This pull request introduces breaking changes.

GitHub

Roadmap

  • Remove tests asserting raw Amanda/TV4 output
    • There isn't much to remove without rewriting the validators (which I would rather refrain from for now)
  • Make TextDiff perform a plain text comparison without any diffs
  • Update the README to mention inferred JSON schema scenario (c6d9906)

@honzajavorek
Copy link
Contributor

honzajavorek commented Jun 26, 2019

Is this WIP or ready to be reviewed? (I don't see the PR as draft PR or the in progress label. But I don't see reviewers assigned either and I do see failing tests, so I'm probably just too proactive 😅 )

@artem-zakharchenko
Copy link
Contributor Author

Sorry, not used to draft feature. This is a WIP (I've attached the label now). You are always welcome to overview, but things may change. I would mainly focus on the gavel-spec representation of our design session (apiaryio/gavel-spec#54), as this pull request would but implement it. Thanks.

@artem-zakharchenko
Copy link
Contributor Author

For the sake of maintaining the scope of this pull request to a reasonable extent, I will rework the internal of certain validators (i.e. TextDiff) according to the new API, but will leave their interfaces intact.

That is because Gavel treats all validators the same, as most of them inherit from the same base class (JsonSchema), and those that do not (TextDiff) mimic the base class methods to allow the same usage during components validation.

As validators are scoped, I would like not to bring up their refactoring at the moment.

@artem-zakharchenko
Copy link
Contributor Author

a95de94 removes diff'ing from TextDiff validator, as we have agreed that Gavel does not perform any kind of diffs. Instead, it checks for strict equality, and returns its verdict alongside expected and actual values. That way the end developer may use whichever diffing algorithm they require.

Also adjusted unit tests for TextDiff to match the changes.

@artem-zakharchenko
Copy link
Contributor Author

It seems I've misconfigured the exclusion of @cli features from Windows tests. Switching to it to fix the build in Appveyor.

@artem-zakharchenko
Copy link
Contributor Author

I've fixed the cli scenarios exclusion in Windows and the build pipeline is green now.

I will look into remaining unit tests, but it looks unlikely to refactor them thoroughly without rewriting the validators (#150), which I would like to omit as a part of this pull request. There is a decent chance this pull request is ready for review. Will confirm explicitly today.

@artem-zakharchenko
Copy link
Contributor Author

Removed surrogate pairs in TextDiff: feaf319
Related issue: #238

Copy link
Contributor

@honzajavorek honzajavorek left a comment

Choose a reason for hiding this comment

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

Awesome job! A lot of good work. I have just a few comments, mostly about leftovers or nitpicks you can even ignore.

Also, I wonder if we could put the Cucumber steps into one files as it's just a few of them now and I don't see much value in having them categorized as general.js or fields.js. But that can be done as a next step with upgrading Cucumber, feel free to ignore the suggestion now.

README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
test/cucumber/support/world.js Outdated Show resolved Hide resolved
test/cucumber/support/world.js Outdated Show resolved Hide resolved
test/cucumber/support/world.js Outdated Show resolved Hide resolved
test/cucumber/support/world.js Outdated Show resolved Hide resolved
test/unit/validators/text-diff-test.js Show resolved Hide resolved
Copy link
Contributor

@honzajavorek honzajavorek left a comment

Choose a reason for hiding this comment

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

Let's do this! 🛫

}
);

this.Then(/^exit status is (\d+)$/, function(expectedStatus) {
assert.equal(this.status, expectedStatus, 'Process statuses do not match');
this.Then(/^exit status is (\d+)$/, function(expectedExitCode) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be nice to change the wording also in the spec for consistency, but let's not bother with this now.

@@ -59,7 +59,7 @@ module.exports = function() {
});

// Vocabulary proxy over the previous action for better scenarios readability.
this.When(/^I call "([^"]*)"$/, function(_command) {
this.When(/^I call "gavel.validate(([^"]*))"$/, function(_, _command) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't it be gavel.validate\(([^\)]*)\)? Not important if it works correctly like this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It does seem to work right now, so we can improve it in #113 :)

@artem-zakharchenko artem-zakharchenko merged commit 0e236bb into master Jul 12, 2019
@artem-zakharchenko artem-zakharchenko deleted the unified-api branch July 12, 2019 12:28
@ApiaryBot
Copy link
Collaborator

🎉 This PR is included in version 7.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants