Skip to content

Commit 37cdba2

Browse files
committed
cargo fmt
1 parent 9168808 commit 37cdba2

1 file changed

Lines changed: 44 additions & 15 deletions

File tree

crates/stackable-operator/src/role_utils.rs

Lines changed: 44 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -418,12 +418,11 @@ where
418418
/// The argument `zero_replicas_counting` is a safety mechanism, which allows the caller to
419419
/// decide if an explicit replica count of `0` should be treated as [`None`]. It also means that
420420
/// [`None`] is returned in case no roleGroups are configured at all.
421-
pub fn fixed_replica_count(
422-
&self,
423-
zero_replicas_counting: ZeroReplicasCounting,
424-
) -> Option<u32> {
421+
pub fn fixed_replica_count(&self, zero_replicas_counting: ZeroReplicasCounting) -> Option<u32> {
425422
// An empty role has no fixed replica count when zeros are treated as None.
426-
if zero_replicas_counting == ZeroReplicasCounting::TreatAsNone && self.role_groups.is_empty() {
423+
if zero_replicas_counting == ZeroReplicasCounting::TreatAsNone
424+
&& self.role_groups.is_empty()
425+
{
427426
return None;
428427
}
429428

@@ -716,45 +715,75 @@ mod tests {
716715
fn replica_counts_with_all_replicas_set() {
717716
let role = construct_role_with_replicas([Some(3), Some(2), Some(5)]);
718717

719-
assert_eq!(role.fixed_replica_count(ZeroReplicasCounting::TreatAsZero), Some(10));
720-
assert_eq!(role.fixed_replica_count(ZeroReplicasCounting::TreatAsNone), Some(10));
718+
assert_eq!(
719+
role.fixed_replica_count(ZeroReplicasCounting::TreatAsZero),
720+
Some(10)
721+
);
722+
assert_eq!(
723+
role.fixed_replica_count(ZeroReplicasCounting::TreatAsNone),
724+
Some(10)
725+
);
721726
assert_eq!(role.estimated_replica_count(), 10);
722727
}
723728

724729
#[test]
725730
fn replica_counts_with_one_replica_unset() {
726731
let role = construct_role_with_replicas([Some(3), None, Some(2)]);
727732

728-
assert_eq!(role.fixed_replica_count(ZeroReplicasCounting::TreatAsZero), None);
729-
assert_eq!(role.fixed_replica_count(ZeroReplicasCounting::TreatAsNone), None);
733+
assert_eq!(
734+
role.fixed_replica_count(ZeroReplicasCounting::TreatAsZero),
735+
None
736+
);
737+
assert_eq!(
738+
role.fixed_replica_count(ZeroReplicasCounting::TreatAsNone),
739+
None
740+
);
730741
assert_eq!(role.estimated_replica_count(), 6);
731742
}
732743

733744
#[test]
734745
fn replica_counts_with_a_zero_replica() {
735746
let role = construct_role_with_replicas([Some(3), Some(0)]);
736747

737-
assert_eq!(role.fixed_replica_count(ZeroReplicasCounting::TreatAsZero), Some(3));
748+
assert_eq!(
749+
role.fixed_replica_count(ZeroReplicasCounting::TreatAsZero),
750+
Some(3)
751+
);
738752
// With treat_zero_as_none the zero turns the whole count into None.
739-
assert_eq!(role.fixed_replica_count(ZeroReplicasCounting::TreatAsNone), None);
753+
assert_eq!(
754+
role.fixed_replica_count(ZeroReplicasCounting::TreatAsNone),
755+
None
756+
);
740757
assert_eq!(role.estimated_replica_count(), 3);
741758
}
742759

743760
#[test]
744761
fn replica_counts_with_a_single_zero_role_group() {
745762
let role = construct_role_with_replicas([Some(0)]);
746763

747-
assert_eq!(role.fixed_replica_count(ZeroReplicasCounting::TreatAsZero), Some(0));
748-
assert_eq!(role.fixed_replica_count(ZeroReplicasCounting::TreatAsNone), None);
764+
assert_eq!(
765+
role.fixed_replica_count(ZeroReplicasCounting::TreatAsZero),
766+
Some(0)
767+
);
768+
assert_eq!(
769+
role.fixed_replica_count(ZeroReplicasCounting::TreatAsNone),
770+
None
771+
);
749772
assert_eq!(role.estimated_replica_count(), 0);
750773
}
751774

752775
#[test]
753776
fn replica_counts_without_role_groups() {
754777
let role = construct_role_with_replicas(vec![]);
755778

756-
assert_eq!(role.fixed_replica_count(ZeroReplicasCounting::TreatAsZero), Some(0));
757-
assert_eq!(role.fixed_replica_count(ZeroReplicasCounting::TreatAsNone), None);
779+
assert_eq!(
780+
role.fixed_replica_count(ZeroReplicasCounting::TreatAsZero),
781+
Some(0)
782+
);
783+
assert_eq!(
784+
role.fixed_replica_count(ZeroReplicasCounting::TreatAsNone),
785+
None
786+
);
758787
assert_eq!(role.estimated_replica_count(), 0);
759788
}
760789

0 commit comments

Comments
 (0)