Matt (pactflow.io / pact-js / pact-go)
Luiz Ramos
03/17/2022, 9:11 PMLuiz Ramos
03/17/2022, 9:48 PMlike
(somethingLike
in SwiftPact)
1. Pact will try to match it as an object
Matchers.somethingLike([
"field1": Matchers.somethingLike("aaa"),
"field2": Matchers.somethingLike(111)
])
Error: wanted key "field1" but found key "abc"
2. If I try to match like this, Pact will try to match it as an array
Matchers.somethingLike([
[
"field1": Matchers.somethingLike("aaa"),
"field2": Matchers.somethingLike(111)
]
])
Error: type mismatch - wanted List but got dictionaryMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
abc
and xyz
keysMatt (pactflow.io / pact-js / pact-go)
Luiz Ramos
03/17/2022, 10:02 PM/endpoint1/dictionary returns
{
"abc": { "field1": "value1", "field2": 123 },
"xyz": { "field1": "value2", "field2": 456 }
}
In my case, "abc" and "xyz" would be the keys. If I don't know them, is it possible to iterate on the "values" of the dictionary while ignoring the keys?
The reason is in my use case, keys can be added or removed at will, but I want to assert that, whenever present, the items in the dictionary have the fields I need.Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Luiz Ramos
03/17/2022, 10:04 PMeachKeyLike
if it's added in future releases. That's good infoLuiz Ramos
03/17/2022, 10:05 PMeachLike
but it seems specific for arrays 👍Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Marko (IttyBittyApps / pact-swift)
03/17/2022, 10:52 PMMatcher
(and look at implementation of some of the existing ones for inspiration. Don’t forget about the tests!):
https://github.com/surpher/PactSwift/blob/main/Sources/Matchers/Matcher.swift
The nastiest of things (due to a Swift bug and still wanting to support macOS 10.x) is you have to specifically handle the matcher in `PactBuilder.swift`:
https://github.com/surpher/PactSwift/blob/main/Sources/PactBuilder.swift#L95Marko (IttyBittyApps / pact-swift)
03/17/2022, 10:54 PMLuiz Ramos
03/22/2022, 8:31 PMLuiz Ramos
03/22/2022, 9:02 PMLuiz Ramos
03/22/2022, 9:02 PMLuiz Ramos
03/23/2022, 2:15 AMMarko (IttyBittyApps / pact-swift)
04/03/2022, 11:44 PMLuiz Ramos
04/05/2022, 3:19 PMMarko (IttyBittyApps / pact-swift)
04/05/2022, 9:43 PMLuiz Ramos
04/12/2022, 4:58 PMMarko (IttyBittyApps / pact-swift)
04/27/2022, 4:17 AMEachKeyLike
matcher implementation @Luiz Ramos?Luiz Ramos
04/27/2022, 4:03 PM