From 08599f28f9ff7956448da6a1404f0d03cf747ac2 Mon Sep 17 00:00:00 2001 From: Ronald Holshausen Date: Sat, 20 Jan 2024 05:46:17 +1100 Subject: [PATCH] chore: Add a test for merging between plugin config and manifest values #41 --- src/server.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/server.rs b/src/server.rs index d5dd976..360009f 100644 --- a/src/server.rs +++ b/src/server.rs @@ -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] @@ -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!{};