diff --git a/fixtures/cache_accept_custom_status_codes/.keep b/fixtures/cache_accept_custom_status_codes/.keep new file mode 100644 index 0000000..e69de29 diff --git a/lychee-bin/tests/cli.rs b/lychee-bin/tests/cli.rs index 8814a45..3c4267e 100644 --- a/lychee-bin/tests/cli.rs +++ b/lychee-bin/tests/cli.rs @@ -753,49 +753,9 @@ mod cli { Ok(()) } - #[tokio::test] - async fn test_skip_cache_unsupported() -> Result<()> { - let base_path = fixtures_path().join("cache"); - let cache_file = base_path.join(LYCHEE_CACHE_FILE); - - // Unconditionally remove cache file if it exists - let _ = fs::remove_file(&cache_file); - - let unsupported_url = "slack://user".to_string(); - let excluded_url = "https://example.com/"; - - // run first without cache to generate the cache file - main_command() - .current_dir(&base_path) - .write_stdin(format!("{unsupported_url}\n{excluded_url}")) - .arg("--cache") - .arg("--verbose") - .arg("--no-progress") - .arg("--exclude") - .arg(excluded_url) - .arg("--") - .arg("-") - .assert() - .stdout(contains(format!( - "[IGNORED] {unsupported_url} | Unsupported: Error creating request client\n" - ))) - .stdout(contains(format!("[EXCLUDED] {excluded_url} | Excluded\n"))); - - // The cache file should be empty, because the only checked URL is - // unsupported and we don't want to cache that. It might be supported in - // future versions. - let buf = fs::read(&cache_file).unwrap(); - assert!(buf.is_empty()); - - // clear the cache file - fs::remove_file(&cache_file)?; - - Ok(()) - } - #[tokio::test] async fn test_lycheecache_accept_custom_status_codes() -> Result<()> { - let base_path = fixtures_path().join("cache"); + let base_path = fixtures_path().join("cache_accept_custom_status_codes"); let cache_file = base_path.join(LYCHEE_CACHE_FILE); // Unconditionally remove cache file if it exists @@ -868,6 +828,46 @@ mod cli { Ok(()) } + #[tokio::test] + async fn test_skip_cache_unsupported() -> Result<()> { + let base_path = fixtures_path().join("cache"); + let cache_file = base_path.join(LYCHEE_CACHE_FILE); + + // Unconditionally remove cache file if it exists + let _ = fs::remove_file(&cache_file); + + let unsupported_url = "slack://user".to_string(); + let excluded_url = "https://example.com/"; + + // run first without cache to generate the cache file + main_command() + .current_dir(&base_path) + .write_stdin(format!("{unsupported_url}\n{excluded_url}")) + .arg("--cache") + .arg("--verbose") + .arg("--no-progress") + .arg("--exclude") + .arg(excluded_url) + .arg("--") + .arg("-") + .assert() + .stdout(contains(format!( + "[IGNORED] {unsupported_url} | Unsupported: Error creating request client\n" + ))) + .stdout(contains(format!("[EXCLUDED] {excluded_url} | Excluded\n"))); + + // The cache file should be empty, because the only checked URL is + // unsupported and we don't want to cache that. It might be supported in + // future versions. + let buf = fs::read(&cache_file).unwrap(); + assert!(buf.is_empty()); + + // clear the cache file + fs::remove_file(&cache_file)?; + + Ok(()) + } + #[test] fn test_verbatim_skipped_by_default() -> Result<()> { let mut cmd = main_command(); @@ -932,7 +932,6 @@ mod cli { .stdout(contains("http://www.example.com/samp")) .stdout(contains("http://www.example.com/kbd")) .stdout(contains("http://www.example.com/var")) - .stdout(contains("http://www.example.com/address")) .stdout(contains("http://www.example.com/script")); Ok(()) }