Skip to content

Commit

Permalink
🎨 cargo clippy & fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
phidiaLam committed Oct 23, 2024
1 parent 0735d3e commit 082b206
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 32 deletions.
2 changes: 1 addition & 1 deletion persistence/database/mongo_connection/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl DbConnectConfig for MongoDbConfig {

fn name(&self) -> &str { &self.db_name }

fn query(&self) -> &HashMap<String, String> { &self.query}
fn query(&self) -> &HashMap<String, String> { &self.query }
}

fn host_default() -> String { "localhost".into() }
Expand Down
45 changes: 14 additions & 31 deletions persistence/database/mongo_connection/src/mongo_connect.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use mongo_migrate_util::MigratorTrait;
use mongodb::{options::ClientOptions, Database};
use url::{ParseError, Url};
use url::Url;

use crate::{
database::builder::DatabaseBuilder, static_vars::set_mongo_database,
Expand Down Expand Up @@ -76,9 +76,10 @@ fn format_url(cfg: &impl DbConnectConfig) -> String {
#[cfg(test)]
mod tests {

use super::*;
use std::collections::HashMap;

use super::*;

#[derive(Debug, serde::Deserialize)]
pub struct MongoDbConfig {
username: String,
Expand All @@ -92,42 +93,24 @@ mod tests {
}

impl DbConnectConfig for MongoDbConfig {
fn scheme(&self) -> &str {
"mongodb"
}
fn scheme(&self) -> &str { "mongodb" }

fn username(&self) -> &str {
&self.username
}
fn username(&self) -> &str { &self.username }

fn password(&self) -> &str {
&self.password
}
fn password(&self) -> &str { &self.password }

fn host(&self) -> &str {
&self.host
}
fn host(&self) -> &str { &self.host }

fn port(&self) -> u16 {
self.port
}
fn port(&self) -> u16 { self.port }

fn name(&self) -> &str {
&self.db_name
}
fn name(&self) -> &str { &self.db_name }

fn query(&self) -> &HashMap<String, String> {
&self.query
}
fn query(&self) -> &HashMap<String, String> { &self.query }
}

fn host_default() -> String {
"localhost".into()
}
fn host_default() -> String { "localhost".into() }

fn port_default() -> u16 {
27017
}
fn port_default() -> u16 { 27017 }

#[test]
fn test_format_url() {
Expand All @@ -144,8 +127,8 @@ mod tests {
query,
};

let expected_url =
"mongodb://user:password@localhost:27017/mydb?authSource=admin&directConnection=true";
let expected_url = "mongodb://user:password@localhost:27017/mydb?\
authSource=admin&directConnection=true";
let result = format_url(&config);
assert_eq!(result, expected_url);
}
Expand Down

0 comments on commit 082b206

Please sign in to comment.