bazel-lib icon indicating copy to clipboard operation
bazel-lib copied to clipboard

[FR]: Support `filter_file` in `assert_json_matches`

Open ARR4N opened this issue 2 years ago • 1 comments

What is the current behavior?

Only string-literal filters can be passed to assert_json_matches, but jq() supports using files.

Describe the feature

Change the signature to:

assert_json_matches(name, file1, file2, filter1 = ".", filter2 = ".", filter_file1 = None, filter_file2 = None, **kwargs):

I'm happy to send a PR if you'd like; please assign the Issue to me if you agree that this is a worthwhile feature.

One problem will be incompatibility between the filter and filter_file args. Thoughts on having filter_file override filter i.f.f. filter == "."? This maintains backwards compatibility while avoiding ambiguity if both are set.

ARR4N avatar May 30 '23 15:05 ARR4N

Sorry for the delay @aschlosberg - your proposal sounds good to me.

alexeagle avatar Jul 06 '23 23:07 alexeagle