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 25, 2024
1 parent 4ff2295 commit 4f16c01
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 4f16c01

Please sign in to comment.