diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/integration/jsr_tests.rs | 25 | ||||
-rw-r--r-- | tests/integration/run_tests.rs | 33 |
2 files changed, 19 insertions, 39 deletions
diff --git a/tests/integration/jsr_tests.rs b/tests/integration/jsr_tests.rs index e72eab1fa..f31b53f27 100644 --- a/tests/integration/jsr_tests.rs +++ b/tests/integration/jsr_tests.rs @@ -1,5 +1,7 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +use deno_cache_dir::HttpCache; +use deno_core::serde_json; use deno_core::serde_json::json; use deno_core::serde_json::Value; use deno_lockfile::Lockfile; @@ -184,13 +186,24 @@ fn reload_info_not_found_cache_but_exists_remote() { let specifier = Url::parse(&format!("http://127.0.0.1:4250/{}/meta.json", package)) .unwrap(); - let registry_json_path = deno_dir - .path() - .join("deps") - .join(deno_cache_dir::url_to_filename(&specifier).unwrap()); - let mut registry_json = registry_json_path.read_json_value(); + let cache = deno_cache_dir::GlobalHttpCache::new( + deno_dir.path().join("deps").to_path_buf(), + deno_cache_dir::TestRealDenoCacheEnv, + ); + let entry = cache + .get(&cache.cache_item_key(&specifier).unwrap(), None) + .unwrap() + .unwrap(); + let mut registry_json: serde_json::Value = + serde_json::from_slice(&entry.content).unwrap(); remove_version(&mut registry_json, version); - registry_json_path.write_json(®istry_json); + cache + .set( + &specifier, + entry.metadata.headers.clone(), + registry_json.to_string().as_bytes(), + ) + .unwrap(); } // This tests that when a local machine doesn't have a version diff --git a/tests/integration/run_tests.rs b/tests/integration/run_tests.rs index deec3d1d4..ad20b77e1 100644 --- a/tests/integration/run_tests.rs +++ b/tests/integration/run_tests.rs @@ -4973,39 +4973,6 @@ console.log(add(3, 4)); } #[test] -fn run_etag_delete_source_cache() { - let test_context = TestContextBuilder::new() - .use_temp_cwd() - .use_http_server() - .build(); - test_context - .temp_dir() - .write("main.ts", "import 'http://localhost:4545/etag_script.ts'"); - test_context - .new_command() - .args("cache main.ts") - .run() - .skip_output_check(); - - // The cache is currently stored unideally in two files where one file has the headers - // and the other contains the body. An issue can happen with the etag header where the - // headers file exists, but the body was deleted. We need to get the cache to gracefully - // handle this scenario. - let deno_dir = test_context.deno_dir().path(); - let etag_script_path = deno_dir.join("deps/http/localhost_PORT4545/26110db7d42c9bad32386735cbc05c301f83e4393963deb8da14fec3b4202a13"); - assert!(etag_script_path.exists()); - etag_script_path.remove_file(); - - test_context - .new_command() - .args("cache --reload --log-level=debug main.ts") - .run() - .assert_matches_text( - "[WILDCARD]Cache body not found. Trying again without etag.[WILDCARD]", - ); -} - -#[test] fn code_cache_test() { let test_context = TestContextBuilder::new().use_temp_cwd().build(); let deno_dir = test_context.deno_dir(); |