Skip to content

Commit

Permalink
Do not push add tag ops when create state op is already pushed
Browse files Browse the repository at this point in the history
create state machine api can handle tags(on the other side, update sfn
api can't), so let it handle tags.
  • Loading branch information
riseshia committed Jul 25, 2024
1 parent 70025df commit ed202ad
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/differ.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ fn build_diff_ops(
let local_state = local_state.unwrap();
let (remote_state, remote_state_tags) = split_sfn_and_tags(remote_state);

let mut need_create_state = false;

if local_config.delete_all {
if remote_state.is_some() {
expected_ops.push(DiffOp::DeleteState);
Expand All @@ -159,9 +161,11 @@ fn build_diff_ops(
}
} else {
expected_ops.push(DiffOp::CreateState);
need_create_state = true;
}

if !expected_ops.contains(&DiffOp::DeleteState) {
// Create ops will handle tags as it is, so dont need to push tags ops
if !expected_ops.contains(&DiffOp::DeleteState) && !need_create_state {
let ops = build_sfn_tags_diff_ops(&local_state_tags, &remote_state_tags);
for op in ops {
expected_ops.push(op);
Expand Down Expand Up @@ -498,11 +502,7 @@ mod test {

assert_eq!(
actual_ops,
vec![
DiffOp::CreateState,
DiffOp::AddStateTag,
DiffOp::CreateSchedule
]
vec![DiffOp::CreateState, DiffOp::CreateSchedule]
);
}

Expand Down Expand Up @@ -769,7 +769,6 @@ mod test {
actual_diff_result.text_diff.clear(); // do not check text_diff
let mut expected_diff_result = DiffResult::default();
expected_diff_result.append_diff_op("HelloWorld", &DiffOp::CreateState);
expected_diff_result.append_diff_op("HelloWorld", &DiffOp::AddStateTag);
expected_diff_result.append_diff_op("HelloWorld", &DiffOp::CreateSchedule);

similar_asserts::assert_eq!(expected_diff_result, actual_diff_result);
Expand Down
1 change: 1 addition & 0 deletions src/types/diff_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub enum DiffOp {
}

impl DiffOp {
// report for user should not show tag api, so, let them be merged into update_state
pub fn op_for_report(op: &DiffOp) -> &DiffOp {
match op {
DiffOp::AddStateTag => &DiffOp::UpdateState,
Expand Down

0 comments on commit ed202ad

Please sign in to comment.