summaryrefslogtreecommitdiffstats
path: root/tests/parse_es_requests.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@archive.org>2020-08-24 13:43:00 -0700
committerBryan Newbold <bnewbold@archive.org>2020-08-24 13:43:00 -0700
commit03bb85c57086e4371d827b5fbd496d3e820496b7 (patch)
tree0b6b74336b6dffe314e952ffb19aea45216b5815 /tests/parse_es_requests.rs
parent95fca87e9f5fae3283ade00363bfd2d094dd0689 (diff)
downloades-public-proxy-03bb85c57086e4371d827b5fbd496d3e820496b7.tar.gz
es-public-proxy-03bb85c57086e4371d827b5fbd496d3e820496b7.zip
tests: try all query files; some small refactors
Diffstat (limited to 'tests/parse_es_requests.rs')
-rw-r--r--tests/parse_es_requests.rs29
1 files changed, 25 insertions, 4 deletions
diff --git a/tests/parse_es_requests.rs b/tests/parse_es_requests.rs
index 01ea64a..57be06a 100644
--- a/tests/parse_es_requests.rs
+++ b/tests/parse_es_requests.rs
@@ -1,20 +1,41 @@
-use es_public_proxy::ApiBody;
+use std::fs;
+use std::ffi::OsStr;
+use es_public_proxy::SearchBody;
mod common;
#[test]
fn basic_load() {
- let request = common::load_request("GET_search");
+ let request = common::load_request_by_name("GET_search");
assert_eq!(request.method, "GET");
assert_eq!(request.path_and_query, "/_search");
}
#[test]
fn basic_parse() {
- let request = common::load_request("GET_search");
+ let request = common::load_request_by_name("GET_search");
assert_eq!(request.method, "GET");
assert_eq!(request.path_and_query, "/_search");
- let thing: ApiBody = serde_json::from_str(&request.body.unwrap()).unwrap();
+ let _parsed: SearchBody = serde_json::from_str(&request.body.unwrap()).unwrap();
+}
+
+#[test]
+fn parse_all_requests() {
+
+ let file_paths = fs::read_dir("tests/files").unwrap();
+
+ for path in file_paths {
+ let path = path.unwrap().path();
+ if path.extension() != Some(OsStr::new("txt")) {
+ continue
+ }
+ let request = common::load_request(&path);
+ if let Some(body) = request.body {
+ println!("parsing: {}", path.display());
+ println!("BODY: {}", body);
+ let _parsed: SearchBody = serde_json::from_str(&body).unwrap();
+ }
+ }
}