summaryrefslogtreecommitdiff
path: root/tests/integration/jupyter_tests.rs
diff options
context:
space:
mode:
authorNathan Whitaker <17734409+nathanwhit@users.noreply.github.com>2024-05-06 16:54:52 -0700
committerGitHub <noreply@github.com>2024-05-06 23:54:52 +0000
commit672216d65a7e737256133615b0bf56092b57b87f (patch)
tree1ee7458192b2e61344fd7e3e2261be6790f5dcbc /tests/integration/jupyter_tests.rs
parent8eb1f11112c3ced0ff4a35f3487a4da507db05c2 (diff)
fix(lsp): Pass diagnostic codes to TSC as numbers (#23720)
Fixes the `Debug Failure` errors described in https://github.com/denoland/deno/issues/23643#issuecomment-2094552765 . The issue here was that we were passing diagnostic codes as strings but TSC expects the codes to be numbers. This resulted in some quick fixes not working (as illustrated by the test added here which fails before this PR). The first commit is the actual fix. The rest are just test related.
Diffstat (limited to 'tests/integration/jupyter_tests.rs')
-rw-r--r--tests/integration/jupyter_tests.rs36
1 files changed, 6 insertions, 30 deletions
diff --git a/tests/integration/jupyter_tests.rs b/tests/integration/jupyter_tests.rs
index 75b1da085..3c4efbdac 100644
--- a/tests/integration/jupyter_tests.rs
+++ b/tests/integration/jupyter_tests.rs
@@ -5,6 +5,7 @@ use std::sync::Arc;
use std::time::Duration;
use bytes::Bytes;
+use test_util::assertions::assert_json_subset;
use test_util::DenoChild;
use test_util::TestContext;
use test_util::TestContextBuilder;
@@ -488,31 +489,6 @@ async fn setup() -> (TestContext, JupyterClient, JupyterServerProcess) {
(context, client, process)
}
-/// Asserts that the actual value is equal to the expected value, but
-/// only for the keys present in the expected value.
-/// In other words, `assert_eq_subset(json!({"a": 1, "b": 2}), json!({"a": 1}))` would pass.
-#[track_caller]
-fn assert_eq_subset(actual: Value, expected: Value) {
- match (actual, expected) {
- (Value::Object(actual), Value::Object(expected)) => {
- for (k, v) in expected.iter() {
- let Some(actual_v) = actual.get(k) else {
- panic!("Key {k:?} not found in actual value ({actual:#?})");
- };
- assert_eq_subset(actual_v.clone(), v.clone());
- }
- }
- (Value::Array(actual), Value::Array(expected)) => {
- for (i, v) in expected.iter().enumerate() {
- assert_eq_subset(actual[i].clone(), v.clone());
- }
- }
- (actual, expected) => {
- assert_eq!(actual, expected);
- }
- }
-}
-
#[tokio::test]
async fn jupyter_heartbeat_echoes() -> Result<()> {
let (_ctx, client, _process) = setup().await;
@@ -531,7 +507,7 @@ async fn jupyter_kernel_info() -> Result<()> {
.await?;
let msg = client.recv(Control).await?;
assert_eq!(msg.header.msg_type, "kernel_info_reply");
- assert_eq_subset(
+ assert_json_subset(
msg.content,
json!({
"status": "ok",
@@ -568,7 +544,7 @@ async fn jupyter_execute_request() -> Result<()> {
.await?;
let reply = client.recv(Shell).await?;
assert_eq!(reply.header.msg_type, "execute_reply");
- assert_eq_subset(
+ assert_json_subset(
reply.content,
json!({
"status": "ok",
@@ -602,7 +578,7 @@ async fn jupyter_execute_request() -> Result<()> {
})
.expect("execution_state idle not found");
assert_eq!(execution_idle.parent_header, request.header.to_json());
- assert_eq_subset(
+ assert_json_subset(
execution_idle.content.clone(),
json!({
"execution_state": "idle",
@@ -615,7 +591,7 @@ async fn jupyter_execute_request() -> Result<()> {
.expect("stream not found");
assert_eq!(execution_result.header.msg_type, "stream");
assert_eq!(execution_result.parent_header, request.header.to_json());
- assert_eq_subset(
+ assert_json_subset(
execution_result.content.clone(),
json!({
"name": "stdout",
@@ -643,7 +619,7 @@ async fn jupyter_store_history_false() -> Result<()> {
let reply = client.recv(Shell).await?;
assert_eq!(reply.header.msg_type, "execute_reply");
- assert_eq_subset(
+ assert_json_subset(
reply.content,
json!({
"status": "ok",