-
Notifications
You must be signed in to change notification settings - Fork 5
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
Host web5 vectors example #66
Conversation
@phoebe-lew mind if i add a |
"errors": { | ||
"type": "boolean", | ||
"default": false, | ||
"description": "Indicates whether the test vector is expected to produce an error. Defaults to false if not present." |
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.
It's unclear to me how errors is meant to work still. Specifically,
- when errors is true, what does the value of output do?
- what do errors translate to in each implementation?
My suggestion is to remove the errors field. Output can encode that an error is expected.
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.
when errors is true, what does the value of output do?
you can omit output
entirely if errors
is true
. that's why neither is a required field. if output
is present, you can omit errors
what do errors translate to in each implementation?
nothing is prescribed here. errors: true
effectively means the code in question should return or throw an error/exception.
general reason for keeping this here is to account for functions that don't return anything on success or throw exceptions
My suggestion is to remove the errors field. Output can encode that an error is expected.
can you provide a concrete example? we're looking to avoid magic strings that mean specific things as much as possible
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.
I was thinking of something along the lines of
{
"output": {
"type": "error",
"message": "my expected error message"
}
}
Regarding
we're looking to avoid magic strings that mean specific things as much as possible
Can you share the motivation? My first instinct is that "error" is already having a specific meaning. Is the line at the top level?
Having a Boolean field can be too vague to be useful in tests. Implementations may easily return a different type of error than what was intended, so I believe it's important to allow that flexibility so implementations can check error messaging.
If we decide that the current schema is the way to go, then I would suggest enforcing that only one of errors
, output
, can be populated, but not both. This can be done with a oneOf
.
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.
Can you share the motivation? My first instinct is that "error" is already having a specific meaning. Is the line at the top level?
was careful to say "avoid magic strings as much as possible" vs. at all because, like you said, the property names themselves are "magic". so more generally, just aiming to limit the use of them as much as possible regardless of level.
having a "type" provides quite a bit of flexibility, which, i'm not sure we necessarily need. could end up with an explosion of custom "types" when it doesn't seem needed (at least imo). doesn't feel like we need to go further than supporting:
- the function works and returns something that should match
output
- the function throws an error (in whatever way the consuming language represents errors)
- optionally, the error's output should match
output
- optionally, the error's output should match
errors: true
effectively means: expect an error in the consuming language.
- so in kotlin or js, whenever
errors: true
, anassertThrows
would be added. - in go i suppose you'd expect
err
to not benil
. - in Rust, you'd want the match to occur on
Result.Err
instead ofResult.Ok
. it's intentionally vague so as not to be too prescriptive for any given implementation. - I tried to provide a COBOL example but Chad made it apparent that COBOL tests are entirely separate programs that have to be written to run on mainframes.
If we decide that the current schema is the way to go, then I would suggest enforcing that only one of errors, output, can be populated, but not both. This can be done with a oneOf.
If we decide that the current schema is the way to go, then I would suggest enforcing that only one of errors, output, can be populated, but not both. This can be done with a oneOf.
i considered this as well initially, but decided not to make them mutually exclusive in order to provide the optionality of using output
for error messages if desired
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 all makes sense to me. Thanks for elaborating.
I would only add that the way to use error and output should be documented in the description field. Specifically the stuff we've talked about in this thread: "when errors is set to true, the output field can be used for further validation. For example, when doing error message validation."
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.
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.
🏅 excited about this
closes #62