Open brento1 opened 2 years ago
Thanks. I don't think it's appropriate to support the UUID directly, but I think the ability to override the default serialisation for non primitives would be better e.g.
type Foo struct {
ID uuid.UUID `json:"id", pact:"match=type,example=27cacc3f-a6ca-4b6d-98f9-c9f7e4e78c07`
Name string `json:"name"`
Description string `json:"description"`
}
Would that work?
In the meantime, you can just fall back to standard matchers, e.g. something like the below:
...
Body: map[string]interface{}{
"uuid": dsl.Like("27cacc3f-a6ca-4b6d-98f9-c9f7e4e78c07"),
"name": dsl.Like("Baz"),
"description": dsl.Like("some user called Baz"),
}
@mefellows Yep totally fine with that option, makes it usable for other non-primitive types that people might be deserializing to. Ideally just want something where I can re-use the same struct in both my Pact tests and my core code, but will use the workaround in the meantime.
Software versions
Expected behaviour
When generating a Pact from a Golang Struct that contains a UUID field, I expect the resulting Pact to contain a String version of the UUID.
Actual behaviour
The resulting Pact contains an array of bytes, which is the UUID fields underlying representation.
Steps to reproduce
The following code is an example on how to reproduce, and the resulting Pact file is below (note the body - ID field)