Skip to content

Commit

Permalink
chore: Add a test for merging between plugin config and manifest values
Browse files Browse the repository at this point in the history
  • Loading branch information
rholshausen committed Jan 19, 2024
1 parent 3c51f8d commit 08599f2
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,10 +1045,11 @@ mod tests {
use pact_plugin_driver::proto::catalogue_entry::EntryType;
use pact_plugin_driver::proto::pact_plugin_server::PactPlugin;
use pact_plugin_driver::proto::start_mock_server_response;
use prost_types::value::Kind;
use serde_json::{json, Map, Value};
use tonic::Request;
use crate::metadata::MetadataMatchResult;

use crate::metadata::MetadataMatchResult;
use crate::server::{merge_value, ProtobufPactPlugin};

#[tokio::test]
Expand Down Expand Up @@ -1185,6 +1186,29 @@ mod tests {
]));
}

#[test]
fn ProtobufPactPlugin__setup_plugin_config__overwrites_manifest_config_from_test_config() {
let manifest = PactPluginManifest {
plugin_config: hashmap!{
"protocVersion".to_string() => json!("1")
},
..PactPluginManifest::default()
};
let plugin = ProtobufPactPlugin { manifest };
let config = btreemap!{
"pact:protobuf-config".to_string() => prost_types::Value { kind: Some(Kind::StructValue(
prost_types::Struct {
fields: btreemap!{
"protocVersion".to_string() => prost_types::Value { kind: Some(Kind::StringValue("2".to_string())) }
}
}))
}
};
expect!(plugin.setup_plugin_config(&config).unwrap()).to(be_equal_to(hashmap!{
"protocVersion".to_string() => json!("2")
}));
}

#[test_log::test]
fn get_mock_server_results_test() {
let mock_results = hashmap!{};
Expand Down

0 comments on commit 08599f2

Please sign in to comment.