Skip to content

tests/krate/publish/keywords: Replace hardcoded error message expectations with insta snapshots #7196

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

Merged
merged 1 commit into from
Sep 27, 2023
Merged
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
15 changes: 3 additions & 12 deletions src/tests/krate/publish/keywords.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,17 @@ fn bad_keywords() {
PublishBuilder::new("foo_bad_key", "1.0.0").keyword("super-long-keyword-name-oh-no");
let response = token.publish_crate(crate_to_publish);
assert_eq!(response.status(), StatusCode::OK);
assert_eq!(
response.into_json(),
json!({ "errors": [{ "detail": "invalid upload request: invalid length 29, expected a keyword with less than 20 characters at line 1 column 203" }] })
);
assert_json_snapshot!(response.into_json());

let crate_to_publish = PublishBuilder::new("foo_bad_key", "1.0.0").keyword("?@?%");
let response = token.publish_crate(crate_to_publish);
assert_eq!(response.status(), StatusCode::OK);
assert_eq!(
response.into_json(),
json!({ "errors": [{ "detail": "invalid upload request: invalid value: string \"?@?%\", expected a valid keyword specifier at line 1 column 178" }] })
);
assert_json_snapshot!(response.into_json());

let crate_to_publish = PublishBuilder::new("foo_bad_key", "1.0.0").keyword("áccênts");
let response = token.publish_crate(crate_to_publish);
assert_eq!(response.status(), StatusCode::OK);
assert_eq!(
response.into_json(),
json!({ "errors": [{ "detail": "invalid upload request: invalid value: string \"áccênts\", expected a valid keyword specifier at line 1 column 183" }] })
);
assert_json_snapshot!(response.into_json());
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
source: src/tests/krate/publish/keywords.rs
expression: response.into_json()
---
{
"errors": [
{
"detail": "invalid upload request: invalid value: string \"?@?%\", expected a valid keyword specifier at line 1 column 178"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
source: src/tests/krate/publish/keywords.rs
expression: response.into_json()
---
{
"errors": [
{
"detail": "invalid upload request: invalid value: string \"áccênts\", expected a valid keyword specifier at line 1 column 183"
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
source: src/tests/krate/publish/keywords.rs
expression: response.into_json()
---
{
"errors": [
{
"detail": "invalid upload request: invalid length 29, expected a keyword with less than 20 characters at line 1 column 203"
}
]
}