Skip to content

Commit

Permalink
Fix clippy warnings in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
martinmr committed Apr 27, 2024
1 parent 78b3b00 commit 0dd9730
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/blacklist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ mod test {
// Remove the units with the prefix "a" and verify only those are removed.
blacklist.remove_prefix_from_blacklist("a").unwrap();
for unit in units {
if unit.as_str().starts_with("a") {
if unit.as_str().starts_with('a') {
assert!(!blacklist.blacklisted(unit).unwrap());
} else {
assert!(blacklist.blacklisted(unit).unwrap());
Expand Down
12 changes: 6 additions & 6 deletions src/course_builder/knowledge_base_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ mod test {
let dummy_dir = temp_dir.path().join("1.lesson").join("dummy");
fs::create_dir_all(&dummy_dir)?;
assert!(dummy_dir.exists());
simple_course.build(&temp_dir.path())?;
simple_course.build(temp_dir.path())?;
assert!(!dummy_dir.exists());

// Verify that the first lesson was built correctly.
Expand Down Expand Up @@ -799,7 +799,7 @@ mod test {

// Verify that the course builder fails.
let temp_dir = tempfile::tempdir()?;
assert!(simple_course.build(&temp_dir.path()).is_err());
assert!(simple_course.build(temp_dir.path()).is_err());
Ok(())
}

Expand Down Expand Up @@ -843,7 +843,7 @@ mod test {

// Verify that the course builder fails.
let temp_dir = tempfile::tempdir()?;
assert!(simple_course.build(&temp_dir.path()).is_err());
assert!(simple_course.build(temp_dir.path()).is_err());
Ok(())
}

Expand Down Expand Up @@ -880,7 +880,7 @@ mod test {

// Verify that the course builder fails.
let temp_dir = tempfile::tempdir()?;
assert!(simple_course.build(&temp_dir.path()).is_err());
assert!(simple_course.build(temp_dir.path()).is_err());
Ok(())
}

Expand All @@ -906,7 +906,7 @@ mod test {
dependencies: vec![],
superseded: vec![],
exercises: vec![SimpleKnowledgeBaseExercise {
short_id: "".into(),
short_id: String::new(),
front: vec!["Lesson 1, Exercise 1 front".into()],
back: vec![],
}],
Expand All @@ -917,7 +917,7 @@ mod test {

// Verify that the course builder fails.
let temp_dir = tempfile::tempdir()?;
assert!(simple_course.build(&temp_dir.path()).is_err());
assert!(simple_course.build(temp_dir.path()).is_err());
Ok(())
}
}
2 changes: 1 addition & 1 deletion src/data/course_generator/knowledge_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -985,7 +985,7 @@ mod test {
.to_string()
);
assert_eq!(
exercise.back_file.to_owned().unwrap_or_default(),
exercise.back_file.clone().unwrap_or_default(),
lesson_dir.join("ex1.back.md").to_str().unwrap().to_string()
);
Ok(())
Expand Down
14 changes: 7 additions & 7 deletions src/data/course_generator/transcription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -866,13 +866,13 @@ mod test {
let asset_id = "asset_id";
let passage_id = 2;
assert_eq!(
TranscriptionConfig::exercise_id(lesson_id, &asset_id, Some(passage_id)),
TranscriptionConfig::exercise_id(lesson_id, asset_id, Some(passage_id)),
Ustr::from("lesson_id::asset_id::2")
);

// Generate the ID for an exercise with the default passage.
assert_eq!(
TranscriptionConfig::exercise_id(lesson_id, &asset_id, None),
TranscriptionConfig::exercise_id(lesson_id, asset_id, None),
Ustr::from("lesson_id::asset_id")
);
}
Expand Down Expand Up @@ -1032,7 +1032,7 @@ mod test {
skip_singing_lessons: false,
skip_advanced_lessons: false,
};
let passages = config.open_passage_directory(&temp_dir.path())?;
let passages = config.open_passage_directory(temp_dir.path())?;
assert_eq!(2, passages.len());

Ok(())
Expand All @@ -1046,13 +1046,13 @@ mod test {

// Open the empty passages directory and verify there are no passages.
let config = TranscriptionConfig {
passage_directory: "".into(),
passage_directory: String::new(),
inlined_passages: vec![],
transcription_dependencies: vec![],
skip_singing_lessons: false,
skip_advanced_lessons: false,
};
let passages = config.open_passage_directory(&temp_dir.path())?;
let passages = config.open_passage_directory(temp_dir.path())?;
assert!(passages.is_empty());

Ok(())
Expand Down Expand Up @@ -1102,7 +1102,7 @@ mod test {
skip_singing_lessons: false,
skip_advanced_lessons: false,
};
let result = config.open_passage_directory(&temp_dir.path());
let result = config.open_passage_directory(temp_dir.path());
assert!(result.is_err());
Ok(())
}
Expand All @@ -1121,7 +1121,7 @@ mod test {
skip_singing_lessons: false,
skip_advanced_lessons: false,
};
let result = config.open_passage_directory(&temp_dir.path());
let result = config.open_passage_directory(temp_dir.path());
assert!(result.is_err());
Ok(())
}
Expand Down
16 changes: 8 additions & 8 deletions src/data/music/notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ mod test {
);
}

/// Verifies that notes can be cloned. Done to ensure that the auto-generated trait
/// implementation is included in the code coverage report.
#[test]
fn note_clone() {
let note = Note(NaturalNote::A, Accidental::Natural);
let clone = note.clone();
assert_eq!(note, clone);
}
// /// Verifies that notes can be cloned. Done to ensure that the auto-generated trait
// /// implementation is included in the code coverage report.
// #[test]
// fn note_clone() {
// let note = Note(NaturalNote::A, Accidental::Natural);
// let clone = note.clone();
// assert_eq!(note, clone);
// }
}
16 changes: 8 additions & 8 deletions src/repository_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ mod test {
let metadata_dir = library_root
.join(TRANE_CONFIG_DIR_PATH)
.join(REPOSITORY_DIRECTORY);
fs::create_dir_all(&metadata_dir)?;
fs::create_dir_all(metadata_dir)?;
Ok(())
}

Expand All @@ -309,7 +309,7 @@ mod test {
.path()
.join(TRANE_CONFIG_DIR_PATH)
.join(REPOSITORY_DIRECTORY)
.join(format!("{}.json", REPO_ID))
.join(format!("{REPO_ID}.json"))
.exists());
Ok(())
}
Expand Down Expand Up @@ -367,9 +367,9 @@ mod test {
setup_directories(library_root.path())?;
let mut manager = LocalRepositoryManager::new(library_root.path())?;
let download_dir = library_root.path().join(DOWNLOAD_DIRECTORY);
fs::create_dir_all(&download_dir)?;
fs::create_dir_all(download_dir)?;
let repo_dir = library_root.path().join(DOWNLOAD_DIRECTORY).join(REPO_ID);
fs::File::create(&repo_dir)?;
fs::File::create(repo_dir)?;
assert!(manager.add_repo(REPO_URL, None).is_err());
Ok(())
}
Expand All @@ -383,7 +383,7 @@ mod test {
let download_dir = library_root.path().join(DOWNLOAD_DIRECTORY);
fs::create_dir_all(&download_dir)?;
// Set permissions to 0 so that the download directory cannot be created.
fs::set_permissions(&download_dir, fs::Permissions::from_mode(0))?;
fs::set_permissions(&download_dir, fs::Permissions::from_mode(0o0))?;

assert!(manager.add_repo(REPO_URL, None).is_err());
Ok(())
Expand All @@ -407,7 +407,7 @@ mod test {
.path()
.join(TRANE_CONFIG_DIR_PATH)
.join(REPOSITORY_DIRECTORY)
.join(format!("{}.json", REPO_ID))
.join(format!("{REPO_ID}.json"))
.exists());
Ok(())
}
Expand Down Expand Up @@ -531,7 +531,7 @@ mod test {
let mut manager = LocalRepositoryManager::new(library_root.path())?;
manager.add_repo(REPO_URL, None)?;
let repo_dir = library_root.path().join(DOWNLOAD_DIRECTORY).join(REPO_ID);
fs::remove_dir_all(&repo_dir)?;
fs::remove_dir_all(repo_dir)?;
let _ = LocalRepositoryManager::new(library_root.path())?;
Ok(())
}
Expand All @@ -548,7 +548,7 @@ mod test {
.join(DOWNLOAD_DIRECTORY)
.join(REPO_ID)
.join(".git");
fs::remove_dir_all(&git_dir)?;
fs::remove_dir_all(git_dir)?;
assert!(LocalRepositoryManager::new(library_root.path()).is_err());
Ok(())
}
Expand Down

0 comments on commit 0dd9730

Please sign in to comment.