Skip to content

Commit c2946d9

Browse files
authored
tests/krate/publish/keywords: Replace hardcoded error message expectations with insta snapshots (#7196)
1 parent 26677f7 commit c2946d9

File tree

4 files changed

+36
-12
lines changed

4 files changed

+36
-12
lines changed

src/tests/krate/publish/keywords.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,26 +22,17 @@ fn bad_keywords() {
2222
PublishBuilder::new("foo_bad_key", "1.0.0").keyword("super-long-keyword-name-oh-no");
2323
let response = token.publish_crate(crate_to_publish);
2424
assert_eq!(response.status(), StatusCode::OK);
25-
assert_eq!(
26-
response.into_json(),
27-
json!({ "errors": [{ "detail": "invalid upload request: invalid length 29, expected a keyword with less than 20 characters at line 1 column 203" }] })
28-
);
25+
assert_json_snapshot!(response.into_json());
2926

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

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

4738
#[test]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
source: src/tests/krate/publish/keywords.rs
3+
expression: response.into_json()
4+
---
5+
{
6+
"errors": [
7+
{
8+
"detail": "invalid upload request: invalid value: string \"?@?%\", expected a valid keyword specifier at line 1 column 178"
9+
}
10+
]
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
source: src/tests/krate/publish/keywords.rs
3+
expression: response.into_json()
4+
---
5+
{
6+
"errors": [
7+
{
8+
"detail": "invalid upload request: invalid value: string \"áccênts\", expected a valid keyword specifier at line 1 column 183"
9+
}
10+
]
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
source: src/tests/krate/publish/keywords.rs
3+
expression: response.into_json()
4+
---
5+
{
6+
"errors": [
7+
{
8+
"detail": "invalid upload request: invalid length 29, expected a keyword with less than 20 characters at line 1 column 203"
9+
}
10+
]
11+
}

0 commit comments

Comments
 (0)