Struct pact_matching::models::Pact
[−]
[src]
pub struct Pact { pub consumer: Consumer, pub provider: Provider, pub interactions: Vec<Interaction>, pub metadata: BTreeMap<String, BTreeMap<String, String>>, pub specification_version: PactSpecification, }
Struct that represents a pact between the consumer and provider of a service.
Fields
consumer: Consumer
Consumer side of the pact
provider: Provider
Provider side of the pact
interactions: Vec<Interaction>
List of interactions between the consumer and provider.
metadata: BTreeMap<String, BTreeMap<String, String>>
Metadata associated with this pact file.
specification_version: PactSpecification
Specification version of this pact
Methods
impl Pact
[src]
fn from_json(file: &String, pact_json: &Value) -> Pact
[src]
Creates a Pact
from a Value
struct.
fn to_json(&self) -> Value
[src]
Converts this pact to a Value
struct.
fn metadata_to_json(&self) -> BTreeMap<String, Value>
[src]
Creates a BTreeMap of the metadata of this pact.
fn merge(&self, pact: &Pact) -> Result<Pact, String>
[src]
Merges this pact with the other pact, and returns a new Pact with the interactions sorted. Returns an error if there is a merge conflict, which will occur if any interaction has the same description and provider state and the requests and responses are different.
fn default_file_name(&self) -> String
[src]
Determins the default file name for the pact. This is based on the consumer and provider names.
fn read_pact(file: &Path) -> Result<Pact>
[src]
Reads the pact file and parses the resulting JSON into a Pact
struct
fn from_url(url: &String) -> Result<Pact, String>
[src]
Reads the pact file from a URL and parses the resulting JSON into a Pact
struct
fn write_pact(&self, path: &Path) -> Result<()>
[src]
Writes this pact out to the provided file path. All directories in the path will automatically created. If an existing pact is found at the path, this pact will be merged into the pact file.
fn default() -> Pact
[src]
Returns a default Pact struct