aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server/tests/integration.rs
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-10-14 14:06:22 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-10-14 14:09:32 +0200
commitb51b7a331ddfd93675e93d88cf267494b9c1b083 (patch)
tree9020aa8c536346285c1f429967e916f738c9e27c /planetwars-server/tests/integration.rs
parent353ecd4c165042234e9f976b158bc970517940f5 (diff)
downloadplanetwars.dev-b51b7a331ddfd93675e93d88cf267494b9c1b083.tar.xz
planetwars.dev-b51b7a331ddfd93675e93d88cf267494b9c1b083.zip
allow filtering for had_errors
Diffstat (limited to 'planetwars-server/tests/integration.rs')
-rw-r--r--planetwars-server/tests/integration.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/planetwars-server/tests/integration.rs b/planetwars-server/tests/integration.rs
index 28cfe1a..0428aa2 100644
--- a/planetwars-server/tests/integration.rs
+++ b/planetwars-server/tests/integration.rs
@@ -389,5 +389,25 @@ async fn test_list_matches_with_errors() -> io::Result<()> {
);
assert_eq!(matches[0]["players"][1]["had_errors"].as_bool(), Some(true));
+ // test had_errors filter
+ // TODO: maybe write a dedicated test for all list_matches options
+ let response = app
+ .call(
+ Request::builder()
+ .method(http::Method::GET)
+ .header("Content-Type", "application/json")
+ .uri(format!("/api/matches?bot=testbot&had_errors=false"))
+ .body(Body::empty())
+ .unwrap(),
+ )
+ .await
+ .unwrap();
+
+ assert_eq!(response.status(), StatusCode::OK);
+ let body = hyper::body::to_bytes(response.into_body()).await.unwrap();
+ let resp: JsonValue = serde_json::from_slice(&body).unwrap();
+
+ let matches = resp["matches"].as_array().unwrap();
+ assert_eq!(matches.len(), 0);
Ok(())
}