Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
worldofjoni committed Oct 26, 2023
1 parent 97c92c9 commit 882760f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions backend/src/startup/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ pub fn print_help() {

/// migrates images from image hoster to local storage.
/// # Errors
/// on problems
/// - invalid file config
/// - invalid database config
/// # Panics
/// never
pub async fn migrate_images() -> Result<(), SubcommandError> {
pub async fn migrate_images(config: &ConfigReader) -> Result<(), SubcommandError> {
info!("Starting image migration...");
let config = ConfigReader::default();

let image_preprocessing = ImagePreprocessor::new(config.read_image_preprocessing_info());
let file_handler = FileHandler::new(config.read_file_handler_info().await.map_err(Box::new)?);
Expand Down Expand Up @@ -168,6 +168,8 @@ pub async fn migrate_images() -> Result<(), SubcommandError> {
#[cfg(test)]
mod tests {

use crate::startup::config::ConfigReader;

use super::{migrate_images, print_help};

#[test]
Expand All @@ -179,6 +181,7 @@ mod tests {
async fn test_migrate_images() {
let dir = tempfile::tempdir().expect("tempdir available");
std::env::set_var("IMAGE_DIR", dir.path().as_os_str());
migrate_images().await.expect("ok");
let reader = ConfigReader::default();
migrate_images(&reader).await.expect("ok");
}
}
2 changes: 1 addition & 1 deletion backend/src/startup/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl Server {
}

if config.should_migrate_images() {
cli::migrate_images().await?;
cli::migrate_images(&config).await?;
return Ok(());

Check warning on line 89 in backend/src/startup/server.rs

View check run for this annotation

Codecov / codecov/patch

backend/src/startup/server.rs#L87-L89

Added lines #L87 - L89 were not covered by tests
}

Expand Down

0 comments on commit 882760f

Please sign in to comment.