Get tests building and sort of passing
This commit is contained in:
61
src/files.rs
61
src/files.rs
@@ -518,6 +518,7 @@ mod tests {
|
||||
use crate::tags::SqliteTagDao;
|
||||
use actix_web::web::Data;
|
||||
use std::{fs, sync::Arc};
|
||||
use actix_web::test::TestRequest;
|
||||
|
||||
fn setup() {
|
||||
let _ = env_logger::builder().is_test(true).try_init();
|
||||
@@ -546,13 +547,9 @@ mod tests {
|
||||
|
||||
let response: HttpResponse = list_photos(
|
||||
claims,
|
||||
TestRequest::default().to_http_request(),
|
||||
request,
|
||||
Data::new(AppState::new(
|
||||
Arc::new(StreamActor {}.start()),
|
||||
String::from("/tmp"),
|
||||
String::from("/tmp/thumbs"),
|
||||
String::from("/tmp/video"),
|
||||
)),
|
||||
Data::new(AppState::test_state()),
|
||||
Data::new(RealFileSystem::new(String::from("/tmp"))),
|
||||
Data::new(Mutex::new(SqliteTagDao::default())),
|
||||
)
|
||||
@@ -588,14 +585,9 @@ mod tests {
|
||||
|
||||
let response = list_photos(
|
||||
claims,
|
||||
HttpRequest::default(),
|
||||
TestRequest::default().to_http_request(),
|
||||
request,
|
||||
Data::new(AppState::new(
|
||||
Arc::new(StreamActor {}.start()),
|
||||
String::from("/tmp"),
|
||||
String::from("/tmp/thumbs"),
|
||||
String::from("/tmp/video"),
|
||||
)),
|
||||
Data::new(AppState::test_state()),
|
||||
Data::new(RealFileSystem::new(String::from("./"))),
|
||||
Data::new(Mutex::new(SqliteTagDao::default())),
|
||||
)
|
||||
@@ -617,12 +609,12 @@ mod tests {
|
||||
|
||||
let mut tag_dao = SqliteTagDao::new(in_memory_db_connection());
|
||||
|
||||
let tag1 = tag_dao.create_tag("tag1").unwrap();
|
||||
let _tag2 = tag_dao.create_tag("tag2").unwrap();
|
||||
let tag3 = tag_dao.create_tag("tag3").unwrap();
|
||||
let tag1 = tag_dao.create_tag(&opentelemetry::Context::current(), "tag1").unwrap();
|
||||
let _tag2 = tag_dao.create_tag(&opentelemetry::Context::current(), "tag2").unwrap();
|
||||
let tag3 = tag_dao.create_tag(&opentelemetry::Context::current(), "tag3").unwrap();
|
||||
|
||||
let _ = &tag_dao.tag_file("test.jpg", tag1.id).unwrap();
|
||||
let _ = &tag_dao.tag_file("test.jpg", tag3.id).unwrap();
|
||||
let _ = &tag_dao.tag_file(&opentelemetry::Context::current(), "test.jpg", tag1.id).unwrap();
|
||||
let _ = &tag_dao.tag_file(&opentelemetry::Context::current(), "test.jpg", tag3.id).unwrap();
|
||||
|
||||
let mut files = HashMap::new();
|
||||
files.insert(
|
||||
@@ -636,14 +628,9 @@ mod tests {
|
||||
|
||||
let response: HttpResponse = list_photos(
|
||||
claims,
|
||||
HttpRequest::default(),
|
||||
TestRequest::default().to_http_request(),
|
||||
request,
|
||||
Data::new(AppState::new(
|
||||
Arc::new(StreamActor {}.start()),
|
||||
String::from(""),
|
||||
String::from("/tmp/thumbs"),
|
||||
String::from("/tmp/video"),
|
||||
)),
|
||||
Data::new(AppState::test_state()),
|
||||
Data::new(FakeFileSystem::new(files)),
|
||||
Data::new(Mutex::new(tag_dao)),
|
||||
)
|
||||
@@ -667,15 +654,15 @@ mod tests {
|
||||
|
||||
let mut tag_dao = SqliteTagDao::new(in_memory_db_connection());
|
||||
|
||||
let tag1 = tag_dao.create_tag("tag1").unwrap();
|
||||
let _tag2 = tag_dao.create_tag("tag2").unwrap();
|
||||
let tag3 = tag_dao.create_tag("tag3").unwrap();
|
||||
let tag1 = tag_dao.create_tag(&opentelemetry::Context::current(), "tag1").unwrap();
|
||||
let _tag2 = tag_dao.create_tag(&opentelemetry::Context::current(), "tag2").unwrap();
|
||||
let tag3 = tag_dao.create_tag(&opentelemetry::Context::current(), "tag3").unwrap();
|
||||
|
||||
let _ = &tag_dao.tag_file("test.jpg", tag1.id).unwrap();
|
||||
let _ = &tag_dao.tag_file("test.jpg", tag3.id).unwrap();
|
||||
let _ = &tag_dao.tag_file(&opentelemetry::Context::current(), "test.jpg", tag1.id).unwrap();
|
||||
let _ = &tag_dao.tag_file(&opentelemetry::Context::current(), "test.jpg", tag3.id).unwrap();
|
||||
|
||||
// Should get filtered since it doesn't have tag3
|
||||
tag_dao.tag_file("some-other.jpg", tag1.id).unwrap();
|
||||
tag_dao.tag_file(&opentelemetry::Context::current(), "some-other.jpg", tag1.id).unwrap();
|
||||
|
||||
let mut files = HashMap::new();
|
||||
files.insert(
|
||||
@@ -695,13 +682,9 @@ mod tests {
|
||||
|
||||
let response: HttpResponse = list_photos(
|
||||
claims,
|
||||
TestRequest::default().to_http_request(),
|
||||
request,
|
||||
Data::new(AppState::new(
|
||||
Arc::new(StreamActor {}.start()),
|
||||
String::from(""),
|
||||
String::from("/tmp/thumbs"),
|
||||
String::from("/tmp/video"),
|
||||
)),
|
||||
Data::new(AppState::test_state()),
|
||||
Data::new(FakeFileSystem::new(files)),
|
||||
Data::new(Mutex::new(tag_dao)),
|
||||
)
|
||||
@@ -772,8 +755,8 @@ mod tests {
|
||||
assert!(is_valid_full_path(&base, &test_file, false).is_some());
|
||||
|
||||
assert_eq!(
|
||||
Some(PathBuf::from("/tmp/test.png")),
|
||||
is_valid_full_path(&base, &PathBuf::from("/tmp/test.png"), false)
|
||||
Some(PathBuf::from(test_file.clone())),
|
||||
is_valid_full_path(&base, &PathBuf::from(test_file), false)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user