mirror of
https://github.com/Hopiu/lychee.git
synced 2026-05-16 01:33:10 +00:00
Put lycheecache tests into separate subfolders to avoid race
This commit is contained in:
parent
388bd20673
commit
86f13609e6
2 changed files with 41 additions and 42 deletions
0
fixtures/cache_accept_custom_status_codes/.keep
vendored
Normal file
0
fixtures/cache_accept_custom_status_codes/.keep
vendored
Normal file
|
|
@ -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(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue