Skip to content

Commit

Permalink
tests/krate/publish/keywords: Replace hardcoded error message expecta…
Browse files Browse the repository at this point in the history
…tions with insta snapshots (#7196)
  • Loading branch information
Turbo87 authored Sep 27, 2023
1 parent 26677f7 commit c2946d9
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 12 deletions.
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"
}
]
}

0 comments on commit c2946d9

Please sign in to comment.