Fix clippy warnings
This commit is contained in:
@@ -4,6 +4,7 @@ pub mod sqlite;
|
||||
|
||||
use async_trait::async_trait;
|
||||
use shared::db_type::DBType;
|
||||
use std::error::Error;
|
||||
use std::future::Future;
|
||||
use std::{pin::Pin, sync::Arc};
|
||||
use url::Host;
|
||||
@@ -55,5 +56,5 @@ pub trait DBInfo<T> {
|
||||
where
|
||||
Self: Sized;
|
||||
async fn get_db_container_config_info(&self) -> DBConfigInfoType;
|
||||
fn get_unstarted_container(&self) -> Result<UnStartedContainer, ()>;
|
||||
fn get_unstarted_container(&self) -> Result<UnStartedContainer, Box<dyn Error>>;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#[derive(Default)]
|
||||
pub struct OptionalContainerConfig {
|
||||
pub image: Option<String>,
|
||||
pub tag: Option<String>,
|
||||
@@ -38,16 +39,3 @@ impl OptionalContainerConfig {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for OptionalContainerConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
image: None,
|
||||
tag: None,
|
||||
container_name: None,
|
||||
database_name: None,
|
||||
user: None,
|
||||
password: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::sync::Arc;
|
||||
use std::{error::Error, sync::Arc};
|
||||
|
||||
use async_trait::async_trait;
|
||||
use testcontainers::{
|
||||
@@ -79,7 +79,7 @@ impl DBInfo<OptionalContainerConfig> for PostgreSQLContainer {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_unstarted_container(&self) -> Result<UnStartedContainer, ()> {
|
||||
fn get_unstarted_container(&self) -> Result<UnStartedContainer, Box<dyn Error>> {
|
||||
Ok(
|
||||
GenericImage::new(self.config.image.clone(), self.config.tag.clone())
|
||||
.with_exposed_port(5432.tcp())
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use std::{path::PathBuf, sync::Arc};
|
||||
use std::{error::Error, path::PathBuf, sync::Arc};
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
@@ -15,6 +15,7 @@ pub struct ContainerConfig {
|
||||
pub absolute_dir_path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct OptionalContainerConfig {
|
||||
// Add any optional configuration fields here
|
||||
pub database_name: Option<String>,
|
||||
@@ -36,15 +37,6 @@ impl OptionalContainerConfig {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for OptionalContainerConfig {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
database_name: None,
|
||||
absolute_path: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_default_config() -> ContainerConfig {
|
||||
ContainerConfig {
|
||||
database_name: "sqlite".to_string(),
|
||||
@@ -83,11 +75,11 @@ impl DBInfo<OptionalContainerConfig> for SQLiteContainer {
|
||||
let db_path = self.get_db_absolute_path();
|
||||
Arc::new(move || {
|
||||
// delete the sqlite database file
|
||||
if db_path.exists() {
|
||||
if let Err(e) = std::fs::remove_file(&db_path) {
|
||||
if db_path.exists()
|
||||
&& let Err(e) = std::fs::remove_file(&db_path)
|
||||
{
|
||||
eprintln!("Failed to delete SQLite database file: {}", e);
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
||||
@@ -107,7 +99,9 @@ impl DBInfo<OptionalContainerConfig> for SQLiteContainer {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_unstarted_container(&self) -> Result<UnStartedContainer, ()> {
|
||||
Err(())
|
||||
fn get_unstarted_container(&self) -> Result<UnStartedContainer, Box<dyn Error>> {
|
||||
Err(Box::new(std::io::Error::other(
|
||||
"SQLite does not use a container",
|
||||
)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ async fn start(config: &Config) {
|
||||
//
|
||||
// write the config files for the api server and database client
|
||||
println!("Writing config files...");
|
||||
write_env_files(&db_config);
|
||||
write_env_files(db_config);
|
||||
println!("Config files written to:");
|
||||
println!(" - {}", to_absolute_path(API_CONFIG_PATH).display());
|
||||
println!(" - {}", to_absolute_path(DB_CONFIG_PATH).display());
|
||||
|
||||
@@ -31,8 +31,8 @@ pub fn write_env_files(db_config: &DBConfigInfoType) {
|
||||
|
||||
let api_env_file = EnvFile {
|
||||
file_type: env::EnvFileType::Yaml,
|
||||
db_type: db_type,
|
||||
db_url: db_url,
|
||||
db_type,
|
||||
db_url,
|
||||
};
|
||||
|
||||
let mut db_env_file = api_env_file.clone();
|
||||
|
||||
Reference in New Issue
Block a user