Skip to content

Commit

Permalink
web/builds: make use of response.json()
Browse files Browse the repository at this point in the history
  • Loading branch information
pflanze committed Jun 27, 2024
1 parent af2656b commit 5d8d1ad
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/web/builds.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,7 @@ mod tests {
{
let response = env.frontend().post("/crate/regex/1.3.1/rebuild").send()?;
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
let text = response.text()?;
let json: serde_json::Value = serde_json::from_str(&text)?;
let json: serde_json::Value = response.json()?;
assert_eq!(
json,
serde_json::json!({
Expand All @@ -405,8 +404,7 @@ mod tests {
{
let response = env.frontend().post("/crate/regex/1.3.1/rebuild").send()?;
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
let text = response.text()?;
let json: serde_json::Value = serde_json::from_str(&text)?;
let json: serde_json::Value = response.json()?;
assert_eq!(
json,
serde_json::json!({
Expand All @@ -423,8 +421,7 @@ mod tests {
.bearer_auth("someinvalidtoken")
.send()?;
assert_eq!(response.status(), StatusCode::UNAUTHORIZED);
let text = response.text()?;
let json: serde_json::Value = serde_json::from_str(&text)?;
let json: serde_json::Value = response.json()?;
assert_eq!(
json,
serde_json::json!({
Expand All @@ -444,8 +441,7 @@ mod tests {
.bearer_auth(correct_token)
.send()?;
assert_eq!(response.status(), StatusCode::CREATED);
let text = response.text()?;
let json: serde_json::Value = serde_json::from_str(&text)?;
let json: serde_json::Value = response.json()?;
assert_eq!(json, serde_json::json!({}));
}

Expand All @@ -459,8 +455,7 @@ mod tests {
.bearer_auth(correct_token)
.send()?;
assert_eq!(response.status(), StatusCode::BAD_REQUEST);
let text = response.text()?;
let json: serde_json::Value = serde_json::from_str(&text)?;
let json: serde_json::Value = response.json()?;
assert_eq!(
json,
serde_json::json!({
Expand Down

0 comments on commit 5d8d1ad

Please sign in to comment.