Skip to content

Commit fc5302a

Browse files
committed
Clean code with clippy and rustfmt
1 parent d24c318 commit fc5302a

9 files changed

Lines changed: 17 additions & 33 deletions

File tree

diesel_cli/src/main.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ use std::{env, fs};
5656
use self::config::Config;
5757
use self::database_error::{DatabaseError, DatabaseResult};
5858
use migrations::MigrationError;
59-
use migrations_internals::{TIMESTAMP_FORMAT};
59+
use migrations_internals::TIMESTAMP_FORMAT;
6060

6161
fn main() {
6262
use self::dotenv::dotenv;
@@ -209,7 +209,7 @@ fn migrations_dir_from_config(matches: &ArgMatches) -> Result<PathBuf, Migration
209209

210210
match migrations_dir {
211211
Some(migrations_dir) => Ok(migrations_dir.file().to_owned()),
212-
None => Err(MigrationError::MigrationDirectoryNotFound)
212+
None => Err(MigrationError::MigrationDirectoryNotFound),
213213
}
214214
}
215215

@@ -232,8 +232,9 @@ fn create_migrations_dir(matches: &ArgMatches) -> DatabaseResult<PathBuf> {
232232
// Retreives and transforms the path of the migrations
233233
// directory from the configuration file or returns the
234234
// default one.
235-
migrations_dir_from_config.ok()
236-
.unwrap_or(project_root.join("migrations"))
235+
migrations_dir_from_config
236+
.ok()
237+
.unwrap_or_else(|| project_root.join("migrations"))
237238
});
238239

239240
if !dir.exists() {

diesel_cli/tests/database_reset.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,10 @@ fn reset_respects_migrations_dir_from_diesel_toml() {
221221
assert!(db.table_exists("posts"));
222222
assert!(db.table_exists("users"));
223223

224-
let result = p
225-
.command("database")
226-
.arg("reset")
227-
.run();
224+
let result = p.command("database").arg("reset").run();
228225

229226
assert!(result.is_success(), "Result was unsuccessful {:?}", result);
230227
assert!(!db.table_exists("posts"));
231228
assert!(db.table_exists("users"));
232229
assert!(db.table_exists("__diesel_schema_migrations"));
233-
}
230+
}

diesel_cli/tests/database_setup.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,7 @@ fn database_setup_respects_migrations_dir_from_diesel_toml() {
172172
// sanity check
173173
assert!(!db.exists());
174174

175-
let result = p
176-
.command("database")
177-
.arg("setup")
178-
.run();
175+
let result = p.command("database").arg("setup").run();
179176

180177
assert!(result.is_success(), "Result was unsuccessful {:?}", result);
181178
assert!(

diesel_cli/tests/migration_generate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,4 +187,4 @@ Creating custom_migrations.12345_stuff.down.sql
187187

188188
assert!(p.has_file("custom_migrations/12345_stuff/up.sql"));
189189
assert!(p.has_file("custom_migrations/12345_stuff/down.sql"));
190-
}
190+
}

diesel_cli/tests/migration_list.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,4 @@ fn migration_list_respects_migrations_dir_from_diesel_toml() {
206206
let result = p.command("migration").arg("list").run();
207207
assert!(result.is_success(), "Result was unsuccessful {:?}", result);
208208
assert!(result.stdout().contains("[X] 12345_create_users_table"));
209-
}
209+
}

diesel_cli/tests/migration_redo.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,7 @@ fn migration_redo_respects_migrations_dir_from_diesel_toml() {
160160
// Make sure the project is setup
161161
p.command("setup").run();
162162

163-
let result = p
164-
.command("migration")
165-
.arg("redo")
166-
.run();
163+
let result = p.command("migration").arg("redo").run();
167164

168165
let expected_stdout = "\
169166
Rolling back migration 12345_create_users_table
@@ -176,4 +173,4 @@ Running migration 12345_create_users_table
176173
"Unexpected stdout {}",
177174
result.stdout()
178175
);
179-
}
176+
}

diesel_cli/tests/migration_revert.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,7 @@ fn migration_revert_respects_migration_dir_from_diesel_toml() {
118118

119119
assert!(db.table_exists("users"));
120120

121-
let result = p
122-
.command("migration")
123-
.arg("revert")
124-
.run();
121+
let result = p.command("migration").arg("revert").run();
125122

126123
assert!(result.is_success(), "Result was unsuccessful {:?}", result);
127124
assert!(
@@ -130,4 +127,4 @@ fn migration_revert_respects_migration_dir_from_diesel_toml() {
130127
result.stdout()
131128
);
132129
assert!(!db.table_exists("users"));
133-
}
130+
}

diesel_cli/tests/migration_run.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -537,10 +537,7 @@ fn migration_run_runs_pending_migrations_custom_migrations_dir_from_diesel_toml(
537537

538538
assert!(!db.table_exists("users"));
539539

540-
let result = p
541-
.command("migration")
542-
.arg("run")
543-
.run();
540+
let result = p.command("migration").arg("run").run();
544541

545542
assert!(result.is_success(), "Result was unsuccessful {:?}", result);
546543
assert!(
@@ -549,4 +546,4 @@ fn migration_run_runs_pending_migrations_custom_migrations_dir_from_diesel_toml(
549546
result.stdout()
550547
);
551548
assert!(db.table_exists("users"));
552-
}
549+
}

diesel_cli/tests/setup.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,7 @@ fn setup_respects_migrations_dir_from_diesel_toml() {
255255

256256
assert!(!p.has_file("custom_migrations"));
257257

258-
let result = p
259-
.command("setup")
260-
.run();
258+
let result = p.command("setup").run();
261259

262260
assert!(result.is_success(), "Result was unsuccessful {:?}", result);
263261
assert!(p.has_file("custom_migrations"));

0 commit comments

Comments
 (0)