Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: remove last trace of workdir/cache... json files, replaced by sql #4128

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 2 additions & 29 deletions src/areas/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

use super::*;
use rusqlite::types::FromSql as _;
use std::cell::RefCell;
use std::io::Write;
use std::rc::Rc;

Expand Down Expand Up @@ -2370,22 +2369,7 @@ fn test_relation_write_missing_housenumbers() {
/// Tests Relation::write_missing_housenumbers(): the case when percent can't be determined.
#[test]
fn test_relation_write_missing_housenumbers_empty() {
let mut ctx = context::tests::make_test_context().unwrap();
let json_value = context::tests::TestFileSystem::make_file();
let files = context::tests::TestFileSystem::make_files(
&ctx,
&[("workdir/cache-empty.json", &json_value)],
);
let mut file_system = context::tests::TestFileSystem::new();
file_system.set_files(&files);
let mut mtimes: HashMap<String, Rc<RefCell<time::OffsetDateTime>>> = HashMap::new();
mtimes.insert(
ctx.get_abspath("workdir/cache-empty.json"),
Rc::new(RefCell::new(time::OffsetDateTime::UNIX_EPOCH)),
);
file_system.set_mtimes(&mtimes);
let file_system_rc: Rc<dyn context::FileSystem> = Rc::new(file_system);
ctx.set_file_system(&file_system_rc);
let ctx = context::tests::make_test_context().unwrap();
let mut relations = Relations::new(&ctx).unwrap();
let relation_name = "empty";
let mut relation = relations.get_relation(relation_name).unwrap();
Expand All @@ -2410,23 +2394,12 @@ fn test_relation_write_missing_housenumbers_interpolation_all() {
},
});
let yamls_cache_value = context::tests::TestFileSystem::write_json_to_file(&yamls_cache);
let json_value = context::tests::TestFileSystem::make_file();
let files = context::tests::TestFileSystem::make_files(
&ctx,
&[
("data/yamls.cache", &yamls_cache_value),
("workdir/cache-budafok.json", &json_value),
],
&[("data/yamls.cache", &yamls_cache_value)],
);
let mut file_system = context::tests::TestFileSystem::new();
file_system.set_files(&files);
let mut mtimes: HashMap<String, Rc<RefCell<time::OffsetDateTime>>> = HashMap::new();
let path = ctx.get_abspath("workdir/cache-budafok.json");
mtimes.insert(
path,
Rc::new(RefCell::new(time::OffsetDateTime::UNIX_EPOCH)),
);
file_system.set_mtimes(&mtimes);
let file_system_rc: Rc<dyn context::FileSystem> = Rc::new(file_system);
ctx.set_file_system(&file_system_rc);
{
Expand Down
35 changes: 3 additions & 32 deletions src/wsgi/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,20 +566,11 @@ fn test_per_relation_lints_out_of_range() {
},
});
let yamls_cache_value = context::tests::TestFileSystem::write_json_to_file(&yamls_cache);
let json_cache_value = context::tests::TestFileSystem::make_file();
let files = context::tests::TestFileSystem::make_files(
&test_wsgi.ctx,
&[
("data/yamls.cache", &yamls_cache_value),
("workdir/cache-gh3073.json", &json_cache_value),
],
&[("data/yamls.cache", &yamls_cache_value)],
);
file_system.set_files(&files);
let mut mtimes: HashMap<String, Rc<RefCell<time::OffsetDateTime>>> = HashMap::new();
mtimes.insert(
test_wsgi.ctx.get_abspath("workdir/cache-gh3073.json"),
Rc::new(RefCell::new(time::OffsetDateTime::UNIX_EPOCH)),
);
let file_system_rc: Rc<dyn context::FileSystem> = Rc::new(file_system);
test_wsgi.ctx.set_file_system(&file_system_rc);
let mtime = test_wsgi.get_ctx().get_time().now_string();
Expand Down Expand Up @@ -826,22 +817,12 @@ fn test_missing_housenumbers_compat_relation() {
}
});
let yamls_cache_value = context::tests::TestFileSystem::write_json_to_file(&yamls_cache);
let jsoncache_value = context::tests::TestFileSystem::make_file();
let files = context::tests::TestFileSystem::make_files(
&test_wsgi.ctx,
&[
("data/yamls.cache", &yamls_cache_value),
("workdir/cache-budafok.json", &jsoncache_value),
],
&[("data/yamls.cache", &yamls_cache_value)],
);
let mut file_system = context::tests::TestFileSystem::new();
file_system.set_files(&files);
let mut mtimes: HashMap<String, Rc<RefCell<time::OffsetDateTime>>> = HashMap::new();
mtimes.insert(
test_wsgi.ctx.get_abspath("workdir/cache-budafok.json"),
Rc::new(RefCell::new(time::OffsetDateTime::UNIX_EPOCH)),
);
file_system.set_mtimes(&mtimes);
let file_system_rc: Rc<dyn context::FileSystem> = Rc::new(file_system);
test_wsgi.ctx.set_file_system(&file_system_rc);
let mtime = test_wsgi.get_ctx().get_time().now_string();
Expand Down Expand Up @@ -970,21 +951,11 @@ fn test_missing_housenumbers_view_result_txt() {
},
});
let yamls_cache_value = context::tests::TestFileSystem::write_json_to_file(&yamls_cache);
let json_cache = context::tests::TestFileSystem::make_file();
let files = context::tests::TestFileSystem::make_files(
&test_wsgi.ctx,
&[
("data/yamls.cache", &yamls_cache_value),
("workdir/cache-budafok.json", &json_cache),
],
&[("data/yamls.cache", &yamls_cache_value)],
);
file_system.set_files(&files);
let mut mtimes: HashMap<String, Rc<RefCell<time::OffsetDateTime>>> = HashMap::new();
mtimes.insert(
test_wsgi.ctx.get_abspath("workdir/cache-budafok.json"),
Rc::new(RefCell::new(time::OffsetDateTime::UNIX_EPOCH)),
);
file_system.set_mtimes(&mtimes);
let file_system_rc: Rc<dyn context::FileSystem> = Rc::new(file_system);
test_wsgi.ctx.set_file_system(&file_system_rc);
let mtime = test_wsgi.get_ctx().get_time().now_string();
Expand Down
16 changes: 1 addition & 15 deletions src/wsgi_json/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@

//! Tests for the wsgi_json module.

use std::cell::RefCell;
use std::collections::HashMap;
use std::io::Write as _;
use std::rc::Rc;

Expand Down Expand Up @@ -243,23 +241,11 @@ fn test_missing_housenumbers_view_result_json() {
},
});
let yamls_cache_value = context::tests::TestFileSystem::write_json_to_file(&yamls_cache);
let json_cache = context::tests::TestFileSystem::make_file();
let files = context::tests::TestFileSystem::make_files(
test_wsgi.get_ctx(),
&[
("data/yamls.cache", &yamls_cache_value),
("workdir/cache-budafok.json", &json_cache),
],
&[("data/yamls.cache", &yamls_cache_value)],
);
file_system.set_files(&files);
let mut mtimes: HashMap<String, Rc<RefCell<time::OffsetDateTime>>> = HashMap::new();
mtimes.insert(
test_wsgi
.get_ctx()
.get_abspath("workdir/cache-budafok.json"),
Rc::new(RefCell::new(time::OffsetDateTime::UNIX_EPOCH)),
);
file_system.set_mtimes(&mtimes);
let file_system_rc: Rc<dyn context::FileSystem> = Rc::new(file_system);
test_wsgi.get_ctx().set_file_system(&file_system_rc);
{
Expand Down