QueryMismatch: Unable to match ["12:13:00"] using Time("HH:mm:ss")
Expected: ["12:13:00"]
Actual: ["12:13:00"]
Parameter: $.item])"
...
2025-01-27T23:15:27.336721Z TRACE ThreadId(02) pactffi_create_mock_server_for_transport{pact=PactHandle { pact_ref: 10669 } addr=0x600000c6a2a0 port=4224 transport=0x600000c6a420 transport_config=0x0}:
pact_ffi::mock_server::handles: with_pact before - ref = 10669,
inner = RefCell { value: PactHandleInner { pact: V4Pact { consumer: Consumer { name: "Consumer" }, provider: Provider { name: "Provider" },
interactions: [SynchronousHttp { id: None, key: None, description: "an interaction with item matching time", provider_states: [],
request: HttpRequest {
method: "GET",
path: "/interaction",
query: Some({"item": [Some("12:13:00")]}),
headers: None,
body: Missing,
matching_rules: MatchingRules {
rules: {PATH: MatchingRuleCategory { name: PATH, rules: {} },
QUERY: MatchingRuleCategory {
name: QUERY,
rules: {DocPath {
path_tokens: [Root, Field("item")], expr: "$.item" }:
RuleList { rules: [Time("HH:mm:ss")],
rule_logic: And, cascaded: false }} }} },
generators: Generators { categories: {} } },
response: HttpResponse { status: 200, headers: None, body: Missing, matching_rules: MatchingRules { rules: {} }, generators: Generators { categories: {} } }, comments: {}, pending: false, plugin_config: {}, interaction_markup: InteractionMarkup { markup: "", markup_type: "" }, transport: None }], metadata: {"namespace1": Object {"name1": String("value1")}, "namespace2": Object {"name2": String("value2")}, "pactRust": Object {"ffi": String("0.4.25")}}, plugin_data: [] }, mock_server_started: false, specification_version: V4 } }
...
----------------------------------------------------------------------------------------
method: GET
path: /interaction
query: Some({"item": [Some("12:13:00")]})
headers: Some({"accept": ["*/*"], "accept-encoding": ["gzip", "deflate"], "connection": ["keep-alive"], "host": ["127.0.0.1:4224"], "user-agent": ["xctest/23600 CFNetwork/1568.300.101 Darwin/24.2.0"], "accept-language": ["en-AU", "en;q=0.9"]})
body: Empty
————————————————————————————————————————————
...
/Users/marko/Developer/pact-foundation/PactSwift/Tests/Model/InteractionQueryTests.swift:200: error: -[PactSwiftTests.InteractionQueryTests testQueryParamMatchingTime] : XCTAssertEqual failed: ("500") is not equal to ("200")
/Users/marko/Developer/pact-foundation/PactSwift/Tests/Model/InteractionQueryTests.swift:194: error: -[PactSwiftTests.InteractionQueryTests testQueryParamMatchingTime] : failed: caught error: "pactFailure([Failure: Request does not match "GET /interaction"
QueryMismatch: Unable to match ["12:13:00"] using Time("HH:mm:ss")
Expected: ["12:13:00"]
Actual: ["12:13:00"]
Parameter: $.item])"
...
🌎 Environment
pact_ffi0.4.25v3,v4💬 Description
Setting up unit tests for
PactSwiftverifying various query parameter usage including time and datetime matchers. When executing the API request and Pact verification, verification fails:🦶 Reproduction Steps
Steps to reproduce the behaviour:
10:13or10:13:00,"pact:matcher:type”: "time”,”format”: “HH:mm”(orHH:mm:ss),GET /endpoint?value=12:13:00,🤔 Expected Results
GETrequest contains exactly the same query parameter as set for thevalueof the matcher.GETrequest contains any valid (date)time value matching the (date)time format set in the matcher😲 Actual Results
Pact test fails when using
Timematcher and sending the request with query parameter value matching the time format set in pact matcher.Pac test fails when using
Datetimematcher and sending the request with query parameter value matching the datetime format set in pact matcher.🌳 Logs
📄 Stack Traces
See attached
query-param-time-matcher-issue.logfor fullstandardOut: .tracelog:query-param-time-matcher-issue.log
🤝 Relationships