-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add failing test cases for autodiscovery #265
base: trunk
Are you sure you want to change the base?
Conversation
8a0a72a
to
afc1054
Compare
pub trait AssertError { | ||
type Item; | ||
fn assert_error(self) -> Self::Item; | ||
} | ||
|
||
impl<T: std::fmt::Debug, E: std::error::Error> AssertError for Result<T, E> { | ||
type Item = E; | ||
|
||
fn assert_error(self) -> E { | ||
assert!(self.is_err(), "Request was successful"); | ||
self.unwrap_err() | ||
} | ||
} |
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 is probably not going to be common enough to have a trait
extension. Also, the Request was successful
might throw us of in the test logs, because it's not clear that it was expected to fail.
In most cases, we need to validate that the request failed with a certain error for which we already have AssertWpError
trait. So, at least for now, I think we should individually implement this assertion and pass in a message that'll point out the issue. If there is enough common usage, then we can implement a specialized one like AssertWpError
.
I realize that we discussed me taking over these PRs and implement them as I see fit, but I just wanted to drop my thoughts here, so if I end up changing it, it doesn't come out of nowhere. 😅
We should probably disable caching for these requests with CACHE_CONTROL & CDN_CACHE_CONTROL headers. What do you think @jkmassel? |
This doesn't work :( I can't get anything like |
Adds some test cases for issues I've seen on real sites:
/wp-json
and seeing if it works. Worst-case, we'd need an entire HTML parser to read the site and see if it's there.reqwest
's options related to that)