Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
quambene committed Jan 29, 2024
1 parent 54c816f commit 250809f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
10 changes: 3 additions & 7 deletions src/cmd/configure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn configure(mut config: Config, args: ConfigArgs) -> Result<(), anyhow::Err
SourceReader::init(source)?;
}

let settings_file = utils::open_file_in_read_write_mode(&config.settings_path)?;
let settings_file = utils::open_and_truncate_file(&config.settings_path)?;

configure_settings(
&mut config.settings,
Expand All @@ -47,8 +47,6 @@ fn configure_settings(
underlying_urls: &[String],
mut writer: impl Write,
) -> Result<(), anyhow::Error> {
let settings_read = settings.clone();

if let Some(source) = source {
settings.set_source(source)?;
}
Expand All @@ -63,10 +61,8 @@ fn configure_settings(
settings.add_underlying_url(underlying_url)?;
}

if &settings_read != settings {
let settings_json = json::serialize(settings)?;
writer.write_all(&settings_json)?;
}
let settings_json = json::serialize(settings)?;
writer.write_all(&settings_json)?;

Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ pub fn open_file_in_read_mode(path: &Path) -> Result<File, BogrepError> {
/// Helper function to open a file in read-write mode.
pub fn open_file_in_read_write_mode(path: &Path) -> Result<File, BogrepError> {
debug!("Open file in read and write mode at {}", path.display());
let file = OpenOptions::new()
let file = File::options()

Check warning on line 88 in src/utils.rs

View check run for this annotation

Codecov / codecov/patch

src/utils.rs#L88

Added line #L88 was not covered by tests
.read(true)
.write(true)
.open(path)
Expand Down

0 comments on commit 250809f

Please sign in to comment.