Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions flipt-evaluation/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,10 +989,11 @@ mod tests {
);

assert!(result_one.is_err());
assert_eq!(
result_one.err().unwrap().to_string(),
"invalid request: error parsing time blah: input contains invalid characters"
);
assert!(result_one
.err()
.unwrap()
.to_string()
.contains("invalid request: error parsing time blah: "));

let result_two = matches_datetime(
&flipt::EvaluationConstraint {
Expand All @@ -1005,10 +1006,11 @@ mod tests {
);

assert!(result_two.is_err());
assert_eq!(
result_two.err().unwrap().to_string(),
"invalid request: error parsing time blah: input contains invalid characters"
);
assert!(result_two
.err()
.unwrap()
.to_string()
.contains("invalid request: error parsing time blah: "));
}

#[test]
Expand Down
11 changes: 3 additions & 8 deletions flipt-evaluation/src/models/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,7 @@ impl Snapshot {
segment_operator: rule.segment_operator,
};

if rule.segments.is_some() {
let rule_segments = rule.segments.unwrap();

if let Some(rule_segments) = rule.segments {
for rule_segment in rule_segments {
let mut eval_constraints: Vec<flipt::EvaluationConstraint> = Vec::new();
for constraint in rule_segment.constraints {
Expand Down Expand Up @@ -137,20 +135,17 @@ impl Snapshot {

evaluation_rollout.rank = rollout_idx;

if rollout.threshold.is_some() {
let threshold = rollout.threshold.unwrap();
if let Some(threshold) = rollout.threshold {
evaluation_rollout.threshold = Some(flipt::RolloutThreshold {
percentage: threshold.percentage,
value: threshold.value,
});

evaluation_rollout.rollout_type = flipt::RolloutType::Threshold;
} else if rollout.segment.is_some() {
} else if let Some(segment_rule) = rollout.segment {
let mut evaluation_rollout_segments: HashMap<String, flipt::EvaluationSegment> =
HashMap::new();

let segment_rule = rollout.segment.unwrap();

for segment in segment_rule.segments {
let mut constraints: Vec<flipt::EvaluationConstraint> = Vec::new();
for constraint in segment.constraints {
Expand Down
Loading