diff options
author | Liam Perlaki <lperlaki@icloud.com> | 2021-01-03 21:31:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-03 21:31:52 +0100 |
commit | 1a2e7741c33490d2a91147966019853c6b1d6a48 (patch) | |
tree | e9e4a645e05d4df780c8f65ff29bb5f7f8d6f7ae /cli/tests | |
parent | 0a509152d16e42f3957a9b2286d5877321d0e331 (diff) |
fix(inspector): add back list endpoint (#8894)
This commit adds back "/json/list" endpoint to
inspector server which was erroneously removed
during server rewrite.
Co-authored-by: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration_tests.rs | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 9400db4ad..2383db0da 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -4345,6 +4345,66 @@ async fn inspector_runtime_evaluate_does_not_crash() { child.wait().unwrap(); } +#[tokio::test] +async fn inspector_json() { + let script = util::tests_path().join("inspector1.js"); + let mut child = util::deno_cmd() + .arg("run") + .arg(inspect_flag_with_unique_port("--inspect")) + .arg(script) + .stderr(std::process::Stdio::piped()) + .spawn() + .unwrap(); + + let stderr = child.stderr.as_mut().unwrap(); + let mut stderr_lines = + std::io::BufReader::new(stderr).lines().map(|r| r.unwrap()); + let ws_url = extract_ws_url_from_stderr(&mut stderr_lines); + let mut url = ws_url.clone(); + let _ = url.set_scheme("http"); + url.set_path("/json"); + let resp = reqwest::get(url).await.unwrap(); + assert_eq!(resp.status(), reqwest::StatusCode::OK); + let endpoint_list = resp + .json::<Vec<deno_core::serde_json::Value>>() + .await + .unwrap(); + let matching_endpoint = endpoint_list + .iter() + .find(|e| e["webSocketDebuggerUrl"] == ws_url.as_str()); + assert!(matching_endpoint.is_some()); +} + +#[tokio::test] +async fn inspector_json_list() { + let script = util::tests_path().join("inspector1.js"); + let mut child = util::deno_cmd() + .arg("run") + .arg(inspect_flag_with_unique_port("--inspect")) + .arg(script) + .stderr(std::process::Stdio::piped()) + .spawn() + .unwrap(); + + let stderr = child.stderr.as_mut().unwrap(); + let mut stderr_lines = + std::io::BufReader::new(stderr).lines().map(|r| r.unwrap()); + let ws_url = extract_ws_url_from_stderr(&mut stderr_lines); + let mut url = ws_url.clone(); + let _ = url.set_scheme("http"); + url.set_path("/json/list"); + let resp = reqwest::get(url).await.unwrap(); + assert_eq!(resp.status(), reqwest::StatusCode::OK); + let endpoint_list = resp + .json::<Vec<deno_core::serde_json::Value>>() + .await + .unwrap(); + let matching_endpoint = endpoint_list + .iter() + .find(|e| e["webSocketDebuggerUrl"] == ws_url.as_str()); + assert!(matching_endpoint.is_some()); +} + #[test] fn websocket() { let _g = util::http_server(); |