-
Notifications
You must be signed in to change notification settings - Fork 9
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
chore(criteria): Unit test that criteria ShEx constraints match non-ShEx constraints #628
Conversation
…pportunityBookableSellerTermsOfService
…epaymentUnavailable
…ops for numeric constraints
if (reqA[fieldName] != null) { | ||
return { [fieldName]: reqA[fieldName] }; | ||
if (extensionConstraint[fieldName] != null && baseConstraint[fieldName] == null) { | ||
return { [fieldName]: extensionConstraint[fieldName] }; | ||
} | ||
if (reqB[fieldName] != null) { | ||
return { [fieldName]: reqB[fieldName] }; | ||
if (baseConstraint[fieldName] != null && extensionConstraint[fieldName] == null) { | ||
return { [fieldName]: baseConstraint[fieldName] }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to me to have been an error. Why have the getValueIfBothExist(..)
invokation down below if we'll never reach that because we would return at the first condition.
// The extension should overwrite the base if they both exist | ||
(base, extension) => extension, | ||
), | ||
...mergeTestDataNodeConstraintField( | ||
'maxinclusive', | ||
baseConstraint, | ||
extensionConstraint, | ||
// The extension should overwrite the base if they both exist | ||
(base, extension) => extension, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes more sense to me given that the language is of a Criteria "extending" another. This is a simpler and more explicit means of doing that (and the previous approach was causing the BookableFiveSpaces criteria to generate a capacity constraint of 2 - 5 rather than just 5)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Closes #592
For each criteria, generate random data from the ShEx constraints, and check that that data matches the non-ShEx constraints, confirming that they are in alignment.
This work also uncovered a few bugs:
termsOfService
constraint in Shape Expression #622It has also spawned a new issue, due to inconsistencies in the modeling presently:
termsOfService
is inconsistent with other ArrayConstraints #629Note to the reviewer:
/built-types/..
files can be ignored during review