Skip to content

Commit

Permalink
use require
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas-Avery committed Apr 2, 2024
1 parent 8006666 commit 292d97c
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions crates/bitwarden/src/secrets_manager/secrets/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use uuid::Uuid;
use super::SecretResponse;
use crate::{
client::encryption_settings::EncryptionSettings,
error::{Error, Result},
error::{require, Result},
Client,
};

Expand Down Expand Up @@ -51,24 +51,19 @@ impl SecretsSyncResponse {
response: SecretsSyncResponseModel,
enc: &EncryptionSettings,
) -> Result<SecretsSyncResponse> {
let has_changes = response.has_changes.ok_or(Error::MissingFields)?;
let has_changes = require!(response.has_changes);

Check warning on line 54 in crates/bitwarden/src/secrets_manager/secrets/sync.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden/src/secrets_manager/secrets/sync.rs#L50-L54

Added lines #L50 - L54 were not covered by tests

if has_changes && response.secrets.is_some() {
let secrets = response
.secrets
.unwrap()
if has_changes {
let secrets = require!(response.secrets)

Check warning on line 57 in crates/bitwarden/src/secrets_manager/secrets/sync.rs

View check run for this annotation

Codecov / codecov/patch

crates/bitwarden/src/secrets_manager/secrets/sync.rs#L56-L57

Added lines #L56 - L57 were not covered by tests
.data
.unwrap_or_default()
.into_iter()
.map(|r| SecretResponse::process_base_response(r, enc))
.collect::<Result<_, _>>()?;

return Ok(SecretsSyncResponse {
has_changes,
secrets: Some(secrets),
});
} else if has_changes && response.secrets.is_none() {
return Err(Error::MissingFields);
}

Ok(SecretsSyncResponse {
Expand Down

0 comments on commit 292d97c

Please sign in to comment.