You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RandomUUID ExampleGenerator is only writing a simple UUID, eg: 22fa4d123c17471bbb6ab57aaa5fb24f into a Pact file. This makes it a bit annoying when expecting uppercased and/or dash separated value.
As an example:
// Let's say Swagger says the value will be a UUID in dashed and uppercased format
// Pact test
// -- code...
body:["id":ExampleGenerator.RandomUUID() // eg: "BDA52033-F0F1-4EC3-8CA4-E04D71572913"
]
// -- code...
PactSwift generates a Pact interaction with the id value of eg: BDA52033-F0F1-4EC3-8CA4-E04D71572913 and passes it to libpact_mock_server_ffi. When FFI is told to generate and write the interactions in a Pact file, a different UUID is generated and written in simple format type, eg: fda98152f0f14ce38aa4b04a54132913.
Because of the above an encodable Swift model that defines a property of type Foundation.UUID fails automatic serialisation unless a custom encodable initialiser is provided. But that could/should be avoided.
π¬ Narrative
When I use ExampleGenerator.RandomUUID()
I want to set a specific format
So that the client validation is easier
π Notes
Even if defining an ExampleGenerator and preparing a Pact file with a specific format for UUID, libpact_mock_server_ffi returns a different UUID in simple format. Will need to work with pact-foundation/pact-reference to support this.
As a workaround until this is implemented, a Matcher.RegexLike(_:term:) can be used instead and providing the UUID value in the expected format.
π¨ Design
N/A
β Acceptance Criteria
GIVEN I use ExampleGenerator.RandomUUID() in a pact test WHEN I run a pact test THEN MockService responds with something like BDA52033-F0F1-4EC3-8CA4-E04D71572913
GIVEN I use ExampleGenerator.RandomUUID(.uppercaseDashed) in a pact test WHEN I run a pact test THEN MockService responds with something like BDA52033-F0F1-4EC3-8CA4-E04D71572913
GIVEN I use ExampleGenerator.RandomUUID(.dashed) in a pact test WHEN I run a pact test THEN MockService responds with something like bda52033-f0f1-4ec3-8ca4-e04d71572913
GIVEN I use ExampleGenerator.RandomUUID(.simple) in a pact test WHEN I run a pact test THEN MockService responds with something like bda52033f0f14ec38ca4e04d71572913