Hey all, I haven't quite found a nice pattern to d...
# general
h
Hey all, I haven't quite found a nice pattern to define consumer pacts when the provider schema with proto3 type
oneof
? Curious if anyone has any matching examples for the following
Copy code
message FooResponse {
  string description = 1;
  repeated Field fields = 2;
}
message Field {
  string id = 1
  oneof field_data {
    TextField textInput = 6;
    ChoiceField choiceInput = 7;
  }
}
example json to match on
Copy code
{
  "description": "foo",
  "fields": [
    {
      "id": "123",
      "textInput": {}
    },
    {
      "id": "123",
      "choice": {}
    }
  ]
}
u
What problem are you getting?
h
Currently I've been writing two pacts for this using min=1 for the fields array and matching it contains each type possible type of object, in this case two different permutations. It feels like I'm not using the tool set right. Any suggestions would be greatly appreciated
In my example above, there are only two choices, but in reality I have more than that. And the best I've come up with is using minLike matcher for a template for each type of possible choice.
Otherwise, if I define one, then it's possible the other choices will break and I wont know.
u
That is the recommended way to use with Pact, have a test for each permutation, and you can control it with provider states.
👍🏽 1
h
ok, so i am doing it right then.