Skip to content

Commit

Permalink
🚨 fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Odonno committed Oct 11, 2023
1 parent 223e408 commit 17c47e5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 28 deletions.
52 changes: 26 additions & 26 deletions src/apply.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,36 +177,11 @@ fn concat_files_content(files: Vec<SurqlFile>) -> String {

ordered_files
.iter()
.map(|file| file.get_content().unwrap_or(String::new()))
.map(|file| file.get_content().unwrap_or_default())
.collect::<Vec<_>>()
.join("\n")
}

#[cfg(test)]
mod tests {
use crate::io::create_surql_file;

use super::*;

#[test]
fn concat_empty_list_of_files() {
let result = concat_files_content(vec![]);
assert_eq!(result, "");
}

#[test]
fn concat_files_in_alphabetic_order() {
let files = vec![
create_surql_file("a.text", "Text of a file"),
create_surql_file("c.text", "Text of c file"),
create_surql_file("b.text", "Text of b file"),
];

let result = concat_files_content(files);
assert_eq!(result, "Text of a file\nText of b file\nText of c file");
}
}

fn get_transaction_action(dry_run: bool) -> TransactionAction {
match dry_run {
true => TransactionAction::Rollback,
Expand Down Expand Up @@ -703,3 +678,28 @@ fn extract_define_event_statements(statements: Vec<Statement>) -> Vec<DefineEven
})
.collect::<Vec<_>>()
}

#[cfg(test)]
mod tests {
use crate::io::create_surql_file;

use super::*;

#[test]
fn concat_empty_list_of_files() {
let result = concat_files_content(vec![]);
assert_eq!(result, "");
}

#[test]
fn concat_files_in_alphabetic_order() {
let files = vec![
create_surql_file("a.text", "Text of a file"),
create_surql_file("c.text", "Text of c file"),
create_surql_file("b.text", "Text of b file"),
];

let result = concat_files_content(files);
assert_eq!(result, "Text of a file\nText of b file\nText of c file");
}
}
2 changes: 1 addition & 1 deletion src/scaffold/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ fn convert_ast_to_surrealdb_schema(

let line_definitions = tables
.entry(table_name)
.or_insert(SurrealdbSchemaDefinition::new());
.or_default();
line_definitions.push(line_definition);
}
_ => {}
Expand Down
2 changes: 1 addition & 1 deletion tests/helpers/surrealdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type SurrealdbTableDefinitions = HashMap<String, String>;
pub async fn get_surrealdb_table_definitions(
db_configuration: Option<SurrealdbConfiguration>,
) -> Result<SurrealdbTableDefinitions> {
let db_configuration = db_configuration.unwrap_or(SurrealdbConfiguration::default());
let db_configuration = db_configuration.unwrap_or_default();
let client = create_surrealdb_client(&db_configuration).await?;

let mut response = client.query("INFO FOR DB;").await?;
Expand Down

0 comments on commit 17c47e5

Please sign in to comment.