Refactor cache configuration
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
use wasmtime_environ::cache_config;
|
||||
use wasmtime_environ::cache_init;
|
||||
|
||||
#[test]
|
||||
fn test_cache_default_config_in_memory() {
|
||||
let errors = cache_config::init::<&str>(true, None, false, None);
|
||||
let errors = cache_init::<&str>(true, None, false, None);
|
||||
assert!(
|
||||
errors.is_empty(),
|
||||
"This test loads config from the default location, if there's one. Make sure it's correct!"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::fs;
|
||||
use tempfile;
|
||||
use wasmtime_environ::cache_config;
|
||||
use wasmtime_environ::cache_init;
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
@@ -20,7 +20,7 @@ fn test_cache_fail_calling_init_twice() {
|
||||
);
|
||||
fs::write(&config_path, config_content).expect("Failed to write test config file");
|
||||
|
||||
let errors = cache_config::init(true, Some(&config_path), false, None);
|
||||
let errors = cache_init(true, Some(&config_path), false, None);
|
||||
assert!(errors.is_empty());
|
||||
let _errors = cache_config::init(true, Some(&config_path), false, None);
|
||||
let _errors = cache_init(true, Some(&config_path), false, None);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use std::fs;
|
||||
use tempfile;
|
||||
use wasmtime_environ::cache_config;
|
||||
use wasmtime_environ::cache_init;
|
||||
|
||||
#[test]
|
||||
fn test_cache_fail_invalid_config() {
|
||||
@@ -18,6 +18,6 @@ fn test_cache_fail_invalid_config() {
|
||||
);
|
||||
fs::write(&config_path, config_content).expect("Failed to write test config file");
|
||||
|
||||
let errors = cache_config::init(true, Some(&config_path), false, None);
|
||||
let errors = cache_init(true, Some(&config_path), false, None);
|
||||
assert!(!errors.is_empty());
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use tempfile;
|
||||
use wasmtime_environ::cache_config;
|
||||
use wasmtime_environ::cache_init;
|
||||
|
||||
#[test]
|
||||
fn test_cache_fail_invalid_path_to_config() {
|
||||
let dir = tempfile::tempdir().expect("Can't create temporary directory");
|
||||
let config_path = dir.path().join("cache-config.toml"); // doesn't exist
|
||||
let errors = cache_config::init(true, Some(&config_path), false, None);
|
||||
let errors = cache_init(true, Some(&config_path), false, None);
|
||||
assert!(!errors.is_empty());
|
||||
}
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
// These tests doesn't call init(), so we can test a multiple certain things here
|
||||
|
||||
use wasmtime_environ::cache_config;
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_cache_fail_usage_without_init_directory() {
|
||||
let _ = cache_config::directory();
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn test_cache_fail_usage_without_init_baseline_compression_level() {
|
||||
let _ = cache_config::baseline_compression_level();
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
use tempfile;
|
||||
use wasmtime_environ::cache_config;
|
||||
use wasmtime_environ::cache_init;
|
||||
|
||||
#[test]
|
||||
fn test_cache_write_default_config() {
|
||||
let dir = tempfile::tempdir().expect("Can't create temporary directory");
|
||||
let config_path = dir.path().join("cache-config.toml");
|
||||
|
||||
let errors = cache_config::init(true, Some(&config_path), true, None);
|
||||
let errors = cache_init(true, Some(&config_path), true, None);
|
||||
assert!(errors.is_empty());
|
||||
assert!(config_path.exists());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user