feat: allow the interaction transport to be set in consumer tests
@@ -19,6 +19,9 @@ pub struct InteractionBuilder {
comments: Vec<String>,
test_name: Option<String>,
+ /// Protocol transport for this interaction
+ transport: Option<String>,
+
/// A builder for this interaction's `Request`.
pub request: RequestBuilder,
@@ -37,6 +40,7 @@ impl InteractionBuilder {
provider_states: vec![],
comments: vec![],
test_name: None,
+ transport: None,
request: RequestBuilder::default(),
response: ResponseBuilder::default(),
}
@@ -65,6 +69,13 @@ impl InteractionBuilder {
self
}
+ /// Sets the protocol transport for this interaction. This would be required when there are
+ /// different types of interactions in the Pact file (i.e. HTTP and messages).
+ pub fn transport<G: Into<String>>(&mut self, name: G) -> &mut Self {
+ self.transport = Some(name.into());
+ self
+ }
+
/// The interaction we've built.
pub fn build(&self) -> RequestResponseInteraction {
RequestResponseInteraction {
@@ -94,7 +105,7 @@ impl InteractionBuilder {
pending: false,
plugin_config: self.plugin_config(),
interaction_markup: self.request.interaction_markup().merge(self.response.interaction_markup()),
- transport: None
+ transport: self.transport.clone()
}
}
