Skip to content

Commit

Permalink
Merge branch 'fix-clippy-warnings-in-tests'
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusPettersson98 committed Nov 23, 2023
2 parents e0e5ab1 + 72297d4 commit 8f39758
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions mullvad-daemon/src/settings/patch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,12 @@ fn merge_patch_to_value(
match (&permitted_key.key_type, current_value, patch_value) {
// Append or replace keys to objects
(
PermittedKeyValue::Object(sub_permitteds),
PermittedKeyValue::Object(sub_permitted),
serde_json::Value::Object(ref mut current),
serde_json::Value::Object(ref patch),
) => {
for (k, sub_patch) in patch {
let Some((_, sub_permitted)) = sub_permitteds
let Some((_, sub_permitted)) = sub_permitted
.iter()
.find(|(permitted_key, _)| k == permitted_key)
else {
Expand Down Expand Up @@ -311,7 +311,7 @@ fn test_permitted_value() {
let patch = r#"{"key": [ {"a": "test" } ] }"#;
let patch: serde_json::Value = serde_json::from_str(patch).unwrap();

validate_patch_value(&PERMITTED_SUBKEYS, &patch, 0).unwrap();
validate_patch_value(PERMITTED_SUBKEYS, &patch, 0).unwrap();
}

#[test]
Expand All @@ -324,12 +324,12 @@ fn test_prohibited_value() {
let patch = r#"{"keyx": [] }"#;
let patch: serde_json::Value = serde_json::from_str(patch).unwrap();

validate_patch_value(&PERMITTED_SUBKEYS, &patch, 0).unwrap_err();
validate_patch_value(PERMITTED_SUBKEYS, &patch, 0).unwrap_err();

let patch = r#"{"key": { "b": 1 } }"#;
let patch: serde_json::Value = serde_json::from_str(patch).unwrap();

validate_patch_value(&PERMITTED_SUBKEYS, &patch, 0).unwrap_err();
validate_patch_value(PERMITTED_SUBKEYS, &patch, 0).unwrap_err();
}

#[test]
Expand All @@ -347,7 +347,7 @@ fn test_merge_append_to_object() {
let patch: serde_json::Value = serde_json::from_str(patch).unwrap();
let expected: serde_json::Value = serde_json::from_str(expected).unwrap();

merge_patch_to_value(&PERMITTED_SUBKEYS, &mut current, &patch, 0).unwrap();
merge_patch_to_value(PERMITTED_SUBKEYS, &mut current, &patch, 0).unwrap();

assert_eq!(current, expected);
}
Expand All @@ -370,7 +370,7 @@ fn test_merge_replace_in_object() {
let patch: serde_json::Value = serde_json::from_str(patch).unwrap();
let expected: serde_json::Value = serde_json::from_str(expected).unwrap();

merge_patch_to_value(&PERMITTED_SUBKEYS, &mut current, &patch, 0).unwrap();
merge_patch_to_value(PERMITTED_SUBKEYS, &mut current, &patch, 0).unwrap();

assert_eq!(current, expected);
}
Expand All @@ -395,7 +395,7 @@ fn test_overflow() {
let patch: serde_json::Value = serde_json::from_str(patch).unwrap();

assert!(matches!(
validate_patch_value(&PERMITTED_SUBKEYS, &patch, 0),
validate_patch_value(PERMITTED_SUBKEYS, &patch, 0),
Err(Error::RecursionLimit)
));
}
Expand All @@ -416,7 +416,7 @@ fn test_patch_relay_override() {
//
let patch = r#"{ "relay_overrides": [ { "invalid": 0 } ] }"#;
let patch: serde_json::Value = serde_json::from_str(patch).unwrap();
validate_patch_value(&PERMITTED_SUBKEYS, &patch, 0).unwrap_err();
validate_patch_value(PERMITTED_SUBKEYS, &patch, 0).unwrap_err();

// If there are no overrides, append new override
//
Expand All @@ -428,8 +428,8 @@ fn test_patch_relay_override() {
let patch: serde_json::Value = serde_json::from_str(patch).unwrap();
let expected: serde_json::Value = serde_json::from_str(expected).unwrap();

validate_patch_value(&PERMITTED_SUBKEYS, &patch, 0).unwrap();
merge_patch_to_value(&PERMITTED_SUBKEYS, &mut current, &patch, 0).unwrap();
validate_patch_value(PERMITTED_SUBKEYS, &patch, 0).unwrap();
merge_patch_to_value(PERMITTED_SUBKEYS, &mut current, &patch, 0).unwrap();

assert_eq!(current, expected);

Expand All @@ -443,8 +443,8 @@ fn test_patch_relay_override() {
let patch: serde_json::Value = serde_json::from_str(patch).unwrap();
let expected: serde_json::Value = serde_json::from_str(expected).unwrap();

validate_patch_value(&PERMITTED_SUBKEYS, &patch, 0).unwrap();
merge_patch_to_value(&PERMITTED_SUBKEYS, &mut current, &patch, 0).unwrap();
validate_patch_value(PERMITTED_SUBKEYS, &patch, 0).unwrap();
merge_patch_to_value(PERMITTED_SUBKEYS, &mut current, &patch, 0).unwrap();

assert_eq!(current, expected);

Expand All @@ -458,8 +458,8 @@ fn test_patch_relay_override() {
let patch: serde_json::Value = serde_json::from_str(patch).unwrap();
let expected: serde_json::Value = serde_json::from_str(expected).unwrap();

validate_patch_value(&PERMITTED_SUBKEYS, &patch, 0).unwrap();
merge_patch_to_value(&PERMITTED_SUBKEYS, &mut current, &patch, 0).unwrap();
validate_patch_value(PERMITTED_SUBKEYS, &patch, 0).unwrap();
merge_patch_to_value(PERMITTED_SUBKEYS, &mut current, &patch, 0).unwrap();

assert_eq!(current, expected);

Expand All @@ -474,8 +474,8 @@ fn test_patch_relay_override() {
let patch: serde_json::Value = serde_json::from_str(patch).unwrap();
let expected: serde_json::Value = serde_json::from_str(expected).unwrap();

validate_patch_value(&PERMITTED_SUBKEYS, &patch, 0).unwrap();
merge_patch_to_value(&PERMITTED_SUBKEYS, &mut current, &patch, 0).unwrap();
validate_patch_value(PERMITTED_SUBKEYS, &patch, 0).unwrap();
merge_patch_to_value(PERMITTED_SUBKEYS, &mut current, &patch, 0).unwrap();

assert_eq!(current, expected);
}

0 comments on commit 8f39758

Please sign in to comment.