You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: tests.rs
    path of file: ./repos/wasmtime/crates/cache/src/config
    
    the code of the file until where you have to start completion: use super::CacheConfig;
use std::fs;
use std::path::PathBuf;
use std::time::Duration;
use tempfile::TempDir;

// note: config loading during validation creates cache directory to canonicalize its path,
//       that's why these function and macro always use custom cache directory
// note: tempdir removes directory when being dropped, so we need to return it to the caller,
//       so the paths are valid
pub fn test_prolog() -> (TempDir, PathBuf, PathBuf) {
    let _ = pretty_env_logger::try_init();
    let temp_dir = tempfile::tempdir().expect("Can't create temporary directory");
    let cache_dir = temp_dir.path().join("cache-dir");
    let config_path = temp_dir.path().join("cache-config.toml");
    (temp_dir, cache_dir, config_path)
}

macro_rules! load_config {
    ($config_path:ident, $content_fmt:expr, $cache_dir:ident) => {{
        let config_path = &$config_path;
        let content = format!($content_fmt, cache_dir = $cache_dir.display());
        fs::write(config_path, content).expect("Failed to write test config file");
        CacheConfig::from_file(Some(config_path)).unwrap()
    }};
}

macro_rules! bad_config {
    ($config_path:ident, $content_fmt:expr, $cache_dir:ident) => {{
        let config_path = &$config_path;
        let content = format!($content_fmt, cache_dir = $cache_dir.display());
        fs::write(config_path, content).expect("Failed to write test config file");
        assert!(CacheConfig::from_file(Some(config_path)).is_err());
    }};
}

// test without macros to test being disabled
#[test]
fn test_disabled() {
    let dir = tempfile::tempdir().expect("Can't create temporary directory");
    let config_path = dir.path().join("cache-config.toml");
    let config_content = "[cache]\n\
                          enabled = false\n";
    fs::write(&config_path, config_content).expect("Failed to write test config file");
    let conf = CacheConfig::from_file(Some(&config_path)).unwrap();
    assert!(!conf.enabled());
}

#[test]
fn test_unrecognized_settings() {
    let (_td, cd, cp) = test_prolog();
    bad_config!(
        cp,
        "unrecognized-setting = 42\
    
fn test_duration_settings() {
    let (_td, cd, cp) = test_prolog();
    let conf = load_config!(
        cp,
        "[cache]\n\
         enabled = true\n\
         directory = '{cache_dir}'\n\
         cleanup-interval = '100s'\n\
         optimizing-compression-task-timeout = '3m'\n\
         allowed-clock-drift-for-files-from-future = '4h'",
        cd
    );
    assert!(conf.enabled());
    assert_eq!(conf.cleanup_interval(), Duration::from_secs(100));
    assert_eq!(
        conf.optimizing_compression_task_timeout(),
        Duration::from_secs(3 * 60)
    );
    assert_eq!(
        conf.allowed_clock_drift_for_files_from_future(),
        Duration::from_secs(4 * 60 * 60)
    );

    let conf = load_config!(
        cp,
        "[cache]\n\
         enabled = true\n\
         directory = '{cache_dir}'\n\
         cleanup-interval = '2d'\n\
         optimizing-compression-task-timeout = '333 m'",
        cd
    );
    assert!(conf.enabled());
    assert_eq!(
        conf.cleanup_interval(),
        Duration::from_secs(2 * 24 * 60 * 60)
    );
    assert_eq!(
        conf.optimizing_compression_task_timeout(),
        Duration::from_secs(333 * 60)
    );

    // different errors
    bad_config!(
        cp,
        "[cache]\n\
         enabled = true\n\
         directory = '{cache_dir}'\n\
         optimizing-compression-task-timeout = '333'",
        cd
    );

    bad_config!(
        cp,
        "[cache]\n\
         enabled = true\n\
         directory = '{cache_dir}'\n\
         optimizing-compression-task-timeout = 333",
        cd
    );

    bad_config!(
        cp,
        "[cache]\n\
         enabled = true\n\
         directory = '{cache_dir}'\n\
         optimizing-compression-task-timeout = '10 M'",
        cd
    );

    bad_config!(
        cp,
        "[cache]\n\
         enabled = true\n\
         directory = '{cache_dir}'\n\
         optimizing-compression-task-timeout = '10 min'",
        cd
    );

    bad_config!(
        cp,
        "[cache]\n\
         enabled = true\n\
         directory = '{cache_dir}'\n\
         optimizing-compression-task-timeout = '-10s'",
        cd
    );

    bad_config!(
        cp,
        "[cache]\n\
         enabled = true\n\
         directory = '{cache_dir}'\n\
         optimizing-compression-task-timeout = '1.5m'",
        cd
    );
}