Skip to content

Commit

Permalink
chore: fix test failing on Windows due to timezone issue #401
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Jan 17, 2023
1 parent 30611e6 commit 7935300
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
package au.com.dius.pact.consumer.dsl

import au.com.dius.pact.core.model.matchingrules.DateMatcher
import au.com.dius.pact.core.model.matchingrules.MatchingRuleCategory
import au.com.dius.pact.core.model.matchingrules.MatchingRuleGroup
import au.com.dius.pact.core.model.matchingrules.RegexMatcher
import au.com.dius.pact.core.model.matchingrules.TimestampMatcher
import au.com.dius.pact.core.model.matchingrules.TypeMatcher
import au.com.dius.pact.core.model.matchingrules.ValuesMatcher
import spock.lang.Issue
import spock.lang.Specification
import spock.lang.Unroll

import java.time.OffsetDateTime
import java.time.ZoneOffset

class DslSpec extends Specification {

@Unroll
Expand All @@ -34,8 +37,9 @@ class DslSpec extends Specification {
@Issue('#401')
def 'eachKeyMappedToAnArrayLike does not work on "nested" property'() {
given:
def instant = OffsetDateTime.of(2000, 2, 1, 0, 0, 0, 0, ZoneOffset.UTC).toInstant()
def body = new PactDslJsonBody()
.date('date', "yyyyMMdd'T'HHmmss")
.datetime('date', "yyyyMMdd'T'HHmmss", instant, TimeZone.getTimeZone('GTM'))
.stringMatcher('system', '.+', 'systemname')
.object('data')
.eachKeyMappedToAnArrayLike('subsystem_name')
Expand All @@ -50,7 +54,7 @@ class DslSpec extends Specification {
result.body.toString() ==
'{"data":{"subsystem_name":[{"id":"1234567"}]},"date":"20000201T000000","system":"systemname"}'
result.matchers == new MatchingRuleCategory('body', [
'$.date': new MatchingRuleGroup([new DateMatcher("yyyyMMdd'T'HHmmss")]),
'$.date': new MatchingRuleGroup([new TimestampMatcher("yyyyMMdd'T'HHmmss")]),
'$.system': new MatchingRuleGroup([new RegexMatcher('.+')]),
'$.data': new MatchingRuleGroup([ValuesMatcher.INSTANCE]),
'$.data.*[*].id': new MatchingRuleGroup([TypeMatcher.INSTANCE])
Expand Down

0 comments on commit 7935300

Please sign in to comment.