MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / test_cache_init

Function test_cache_init

crates/cache/src/tests.rs:11–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9
10#[test]
11fn test_cache_init() {
12 let (_tempdir, cache_dir, config_path) = test_prolog();
13 let baseline_compression_level = 4;
14 let config_content = format!(
15 "[cache]\n\
16 directory = '{}'\n\
17 baseline-compression-level = {}\n",
18 cache_dir.display(),
19 baseline_compression_level,
20 );
21 fs::write(&config_path, config_content).expect("Failed to write test config file");
22
23 let cache_config = CacheConfig::from_file(Some(&config_path)).unwrap();
24
25 // assumption: config init creates cache directory and returns canonicalized path
26 assert_eq!(
27 cache_config.directory(),
28 Some(&fs::canonicalize(cache_dir).unwrap())
29 );
30 assert_eq!(
31 cache_config.baseline_compression_level(),
32 baseline_compression_level
33 );
34
35 // test if we can use worker
36 Cache::new(cache_config)
37 .unwrap()
38 .worker()
39 .on_cache_update_async(config_path);
40}
41
42#[test]
43fn test_write_read_cache() {

Callers

nothing calls this directly

Calls 7

test_prologFunction · 0.85
workerMethod · 0.80
writeFunction · 0.50
newFunction · 0.50
expectMethod · 0.45
unwrapMethod · 0.45
on_cache_update_asyncMethod · 0.45

Tested by

no test coverage detected