summaryrefslogtreecommitdiffstats
path: root/tests/parse_es_requests.rs
diff options
context:
space:
mode:
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();
+ }
+ }
}