Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(remap): condition without subfields is set to Remap source #6255

Merged
merged 3 commits into from
Jan 31, 2021

Conversation

StephenWakely
Copy link
Contributor

Ref #4791

This updates the conditions such that if you don't specify a subfield it will take the value as the remap source.

So both these examples work and are equivalent:

[transforms.filter]
  type = "filter"
  inputs = ["stdin"]
  condition.type = "remap"
  condition.source = 'contains!(.message, "funky")'
  type = "filter"
  inputs = ["stdin"]
  condition = 'contains!(.message, "funky")'

check_fields conditions work and can be set as before. A deprecation warning is still emitted.

Signed-off-by: Stephen Wakely [email protected]

@StephenWakely StephenWakely requested review from a team January 27, 2021 10:47
@binarylogic
Copy link
Contributor

Thanks! Just making sure these tests are adequate. We've been bitten by these types of changes in the past. Would it make sense to add a behavior test for the new remap syntax?

@StephenWakely
Copy link
Contributor Author

We've been bitten by these types of changes in the past. Would it make sense to add a behavior test for the new remap syntax?

I have already moved all the behaviour tests over to Remap in a previous PR, but I have left them specifying the type="remap. It seems the unit tests actually take an array of conditions so rather than specifying them as they currently are:

    [[tests.outputs.conditions]]
      type = "remap"
      source = '''
        .a.b == 123 && \
        .x.y == 456 && \
        .x.z == 789
      '''

you can do:

    conditions = ['''
        .a.b == 123 && \
        .x.y == 456 && \
        .x.z == 789
      ''']

I didn't like the way this looked at first, so I hesitated to change it. But I'm actually warming to it now that I type this comment. I'll move them over...

@binarylogic binarylogic requested review from bruceg, fanatid and pablosichert and removed request for a team January 28, 2021 16:26
src/conditions/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@bruceg bruceg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I echo @pablosichert's test concerns, but otherwise LGTM

src/conditions/mod.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@pablosichert pablosichert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some suggestions, otherwise LGTM

Signed-off-by: Stephen Wakely <[email protected]>
.unwrap();

assert_eq!(
r#"Map(RemapConfig { source: ".nork == true" }"#,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
r#"Map(RemapConfig { source: ".nork == true" }"#,
r#"Map(RemapConfig { source: ".nork == true" })"#,

Same for 2 tests above. Rest looks good 👍

Signed-off-by: Stephen Wakely <[email protected]>
@binarylogic binarylogic merged commit 9fc8dac into master Jan 31, 2021
@binarylogic binarylogic deleted the 4791_remap_conditions branch January 31, 2021 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants