Spring-cloud-contract: execute on header value Generates assertThat() instead of method call

Created on 12 Sep 2018  路  7Comments  路  Source: spring-cloud/spring-cloud-contract

This worked in version 1.2.4. Does not in 2.0.1:

...
response {
    status 201

    headers {
      // pass the value of the location header to the test for validation
      header('location', producer(execute('assertLocation($it)')))
    }
  }

results in:

error: 'void' type not allowed here

assertThat(response.header("location")).isEqualTo(assertLocation(response.header("location")));

It used to call the assertLocation(value of location header) in the base class. Am I doing it wrong?

bug

All 7 comments

assertThat(response.header("location")).isEqualTo(assertLocation(response.header("location")));

It's exactly doing the same thing.

assertLocation($it) -> assertLocation(response.header("location"))

How would you want this to behave?

ah I see, you say that

assertThat(response.header("location")).isEqualTo(assertLocation(response.header("location")));

should be

assertLocation(response.header("location"));

I have the culprit - https://github.com/spring-cloud/spring-cloud-contract/issues/628
and the commit https://github.com/spring-cloud/spring-cloud-contract/commit/077e18aa259e9ac0999d4435c056a3fca56a127f

@OlgaMaciaszek, @TYsewyn we'll have to think how to make those two approaches work together. Anyways, we broke the compatibility :(

@kpb @marcingrzejszczak @TYsewyn It looks like, in fact, https://github.com/spring-cloud/spring-cloud-contract/issues/628 was not valid. I have added a comment there explaining why. I'm going to revert this change, which will fix this issue.

Thank you! What release will this be included in? And, any idea when the release will happen?

You can check https://github.com/spring-cloud/spring-cloud-release/milestones for the dates. We will plan on doing Edgware and Finchley releases soon. When we know the dates, we'll update the calendar.

Was this page helpful?
0 / 5 - 0 ratings