Skip to content

tests: Fix tests failures when testing against 1.15.1 #673

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,15 +395,15 @@ mod test {
reqwest::Client::new()
.execute(reqwest::Request::new(
reqwest::Method::POST,
// there will never be a `meilisearch.gouv.fr` addr since these domain name are controlled by the state of france
// there will never be a `meilisearch.gouv.fr` addr since these domain names are controlled by the state of france
reqwest::Url::parse("https://meilisearch.gouv.fr").unwrap(),
))
.await
.unwrap_err(),
);
assert_eq!(
error.to_string(),
"HTTP request failed: error sending request for url (https://meilisearch.gouv.fr/)"
"HTTP request failed: error sending request"
);
Comment on lines +398 to 407
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

❓ Verification inconclusive

Assertion on exact reqwest error string is brittle – prefer substring or prefix match.

reqwest’s error wording ("error sending request") can differ between patch versions, features (native-tls/rustls), or OS.
Relying on full equality risks false failures the next time reqwest bumps.

-assert_eq!(
-    error.to_string(),
-    "HTTP request failed: error sending request"
-);
+assert!(
+    error.to_string().starts_with("HTTP request failed:"),
+    "Unexpected reqwest error format: {}",
+    error
+);

This keeps the intent (we got an HTTP error) while de-flaking the test.


Prefer substring match over exact reqwest error string

Matching the full reqwest error message can break tests when minor wording or feature differences occur. It’s safer to assert on a static prefix and include the actual error in the failure message.

• File: src/errors.rs
Lines: 398–407

- assert_eq!(
-     error.to_string(),
-     "HTTP request failed: error sending request"
- );
+ assert!(
+     error.to_string().starts_with("HTTP request failed:"),
+     "Unexpected reqwest error format: {}",
+     error
+ );
🤖 Prompt for AI Agents
In src/errors.rs around lines 398 to 407, the test asserts exact equality on the
reqwest error string, which is brittle due to possible variations in error
wording across versions and platforms. Modify the assertion to check that the
error string starts with or contains a stable substring like "HTTP request
failed" instead of exact equality. This ensures the test verifies the error type
without breaking on minor message changes.


let error = Error::InvalidTenantToken(jsonwebtoken::errors::Error::from(InvalidToken));
Expand Down
3 changes: 3 additions & 0 deletions src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@ pub enum Action {
/// Provides access to everything.
#[serde(rename = "*")]
All,
/// Provides access to the `/chatCompletions` endpoint, since Meilisearch 1.15.1.
#[serde(rename = "chatCompletions")]
ChatCompletions,
/// Provides access to both [`POST`](https://www.meilisearch.com/docs/reference/api/search#search-in-an-index-with-post-route) and [`GET`](https://www.meilisearch.com/docs/reference/api/search#search-in-an-index-with-get-route) search endpoints on authorized indexes.
#[serde(rename = "search")]
Search,
Expand Down