Petr Šebek
01/25/2023, 2:36 PMclass TestEnumV1(str, Enum):
OPTION_1 = "option_1"
OPTION_2 = "option_2"
OPTION_3 = "option_3"
class TestEnumV2(str, Enum):
OPTION_1 = "option_1"
OPTION_2 = "option_2"
OPTION_3 = "option_3"
OPTION_4 = "option_4"
Note that TestEnumV2
has extra OPTION_4
. I'm sending these messages as JSONs so it will be serialized as "option_4" string. Now TestEnumV1
and TestEnumV2
are not compatible because if publisher sends "option_4"
to a subscriber understanding only TestEnumV1
it will fail because subscriber will not know that value in TestEnumV1
.
However, if I write consumer matcher as pact.Like(TestEnumV1.OPTION_1)
it will happily accept any string.
I can write a regex for it pact.Term(r"^option_1|option_2|option_3$", "option_1")
which would resolve it on consumer side.
But what should I do on provider side? Should I generate and test message with every enum value possible?
Is this (consumer and provider parts) how it should be done?