karate icon indicating copy to clipboard operation
karate copied to clipboard

Karate contains only shortcut fails in v1.2.0 contains deep steps

Open CleanHit opened this issue 1 year ago • 6 comments

I'm updating karate v1.01 to v1.2.0. This small scenario will fail in karate v1.2.0 but will succeed in v1.0.1

@test_contains_only
Scenario: Test contains only shortcut
  * def expected = [ "a", "b", "c", "d" ]
  * def to_match = { "properties": { "additional_information": "Some put-updated info", "types": [ "a", "b", "c", "d" ] } }
  * match to_match.properties contains deep { "types": '#(^^expected)' }

The same behavior was spotted on my side for additional contains shortcuts, e.g. ^+ and ^*.

CleanHit avatar Jul 22 '22 12:07 CleanHit

@CleanHit thanks, I really appreciate the simple example

ptrthomas avatar Jul 22 '22 14:07 ptrthomas

@ptrthomas you're welcome. I see that there was a discussion about this behavior in this https://github.com/karatelabs/karate/issues/1721 issue. The reporter had the same problem as me with v1.1.0. If the intended behavior is not to mix contains deep with other contains shortcuts, then this issue can be closed.

I'm not that familiar with the code, but I guess that everything that has to do with matchers is being handled in those files

Since this behavior was spotted in the change from v1.0.1 to v1.1.0, I've compared the two releases. The only # related changes that I could see were done in karate-core/src/main/java/com/intuit/karate/MatchOperation.java file. I don't know if moving the block in lines 185 - 197 to lines 217 - 229 might have caused this behavior.

EDIT: After looking at the error I'm getting "all key-values did not match, expected has un-matched keys - [types] (MAP:MAP)", I think it might be more related to the changes done in the private boolean matchMapValues() function (https://github.com/karatelabs/karate/blob/v1.1.0/karate-core/src/main/java/com/intuit/karate/MatchOperation.java), The only visible changes are in lines 504 - 513.

CleanHit avatar Jul 22 '22 19:07 CleanHit

@CleanHit thanks for the hints, it helped. is fixed in develop

ptrthomas avatar Aug 03 '22 06:08 ptrthomas

@ptrthomas Thank you. I'll try to test it on my side as soon as the change will be part of some Gradle release candidate package.

CleanHit avatar Aug 04 '22 06:08 CleanHit

@ptrthomas I'm closing this ticket as I've successfully tested it with 1.3.0.RC2.

CleanHit avatar Sep 08 '22 13:09 CleanHit

@CleanHit thank you ! we follow a (what I realize may be a non-typical) process where we mark as fixed and close when the final non-RC release goes out, release notes and all, so I'll keep this open for now

ptrthomas avatar Sep 08 '22 13:09 ptrthomas

1.3.0 released

ptrthomas avatar Nov 02 '22 17:11 ptrthomas