summaryrefslogtreecommitdiff
path: root/tests/integration/jsr_tests.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2024-08-26 19:59:17 -0400
committerGitHub <noreply@github.com>2024-08-26 23:59:17 +0000
commitc89a20b42899abff5c3ea84660c8110806c5fbee (patch)
treee9d93ce49b391faf0058bd3223ba72d398f78fc8 /tests/integration/jsr_tests.rs
parente13230226fe91498b3a5f28a8de6edbe4f164944 (diff)
perf(cache): single cache file for remote modules (#24983)
This changes the global cache to store the cache file for remote modules in one file instead of two.
Diffstat (limited to 'tests/integration/jsr_tests.rs')
-rw-r--r--tests/integration/jsr_tests.rs25
1 files changed, 19 insertions, 6 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(&registry_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